[Prism54-devel] Patch to control output power (iwconfig txpower)

kaleda gadeanta@soften.ktu.lt
Fri, 19 Dec 2003 15:25:25 +0200


Made a patch to manage output power.
Currently only fixed value is supported
(I think the main in AP mode).
Still don't know a way to turn off the radio (anyone knows it) ?

Kaleda

diff -uNr prism54.orig/ksrc/isl_ioctl.c prism54/ksrc/isl_ioctl.c
--- prism54.orig/ksrc/isl_ioctl.c	2003-12-17 08:16:38.000000000 +0200
+++ prism54/ksrc/isl_ioctl.c	2003-12-19 14:04:28.000000000 +0200
@@ -880,6 +880,9 @@
 	range->max_retry = 65535;
 	range->min_r_time = 1024;
 	range->max_r_time = 65535 * 1024;
+	
+	/* txpower is supported in dBm's */
+	range->txpower_capa = IW_TXPOW_DBM;
 
 	/* Request the device for the supported frequencies
 	 * not really revelant since some devices will report the 5 GHz band
@@ -1638,6 +1641,47 @@
 	return 0;
 }
 
+
+int prism54_get_txpower(struct net_device *ndev, struct iw_request_info
*info,
+		struct iw_param *vwrq, char *extra)
+{
+	islpci_private *priv = ndev->priv;
+	u32 u;
+	memset(vwrq, 0, sizeof(struct iw_param));
+	MGT_GET_REQUEST_U32(priv, OID_INL_OUTPUTPOWER, &u, fixedtxpower);
+	// intersil firmware operates in 0.25 dBm (1/4 dBm)
+	vwrq->value = u / 4;
+	vwrq->fixed = 1;	// fixed value is set
+	// radio is not turned of
+	// btw: how is possible to turn off only the radio ?
+	vwrq->disabled = 0; 
+	return 0;
+}	//	isl_ioctl_gettxpow
+
+int prism54_set_txpower(struct net_device *ndev, struct iw_request_info
*info,
+		struct iw_param *vwrq, char *extra)
+{
+	islpci_private *priv = ndev->priv;
+	// intersil firmware operates in 0.25 dBm (1/4)
+	u32 u = vwrq->value;
+	u *= 4;
+	if (vwrq->disabled) {
+		// don't know how to disable radio
+		printk(KERN_DEBUG "%s: %s() disabling radio is not yet supported.\n",
priv->ndev->name, __FUNCTION__);
+		return -ENOTSUPP;
+	} else if (vwrq->fixed)	{
+		// currently only fixed value is supported
+		MGT_SET_REQUEST_U32(priv, OID_INL_OUTPUTPOWER , u, fixedtxpower);
+		return 0;
+	} else {
+		printk(KERN_DEBUG "%s: %s() auto power will be implemented later.\n",
+				priv->ndev->name, __FUNCTION__);
+		return -ENOTSUPP;
+	}
+}	//	isl_ioctl_settxpow
+
+
+
 int
 prism54_reset(struct net_device *ndev, struct iw_request_info *info,
 	      __u32 *uwrq, char *extra)
diff -uNr prism54.orig/ksrc/isl_ioctl.h prism54/ksrc/isl_ioctl.h
--- prism54.orig/ksrc/isl_ioctl.h	2003-12-17 08:16:38.000000000 +0200
+++ prism54/ksrc/isl_ioctl.h	2003-12-19 10:36:12.000000000 +0200
@@ -94,6 +94,10 @@
 		       struct iw_point *, char *);
 int prism54_get_encode(struct net_device *, struct iw_request_info *,
 		       struct iw_point *, char *);
+int prism54_set_txpower(struct net_device *, struct iw_request_info *,
+		     struct iw_param *, char *);
+int prism54_get_txpower(struct net_device *, struct iw_request_info *,
+		     struct iw_param *, char *);
 
 int prism54_reset(struct net_device *, struct iw_request_info *,
 		  __u32 *, char *);
@@ -189,8 +193,8 @@
 	(iw_handler) prism54_get_rts,	/* SIOCGIWRTS */
 	(iw_handler) prism54_set_frag,	/* SIOCSIWFRAG */
 	(iw_handler) prism54_get_frag,	/* SIOCGIWFRAG */
-	(iw_handler) NULL,	/* SIOCSIWTXPOW */
-	(iw_handler) NULL,	/* SIOCGIWTXPOW */
+	(iw_handler) prism54_set_txpower,	/* SIOCSIWTXPOW */
+	(iw_handler) prism54_get_txpower,	/* SIOCGIWTXPOW */
 	(iw_handler) prism54_set_retry,	/* SIOCSIWRETRY */
 	(iw_handler) prism54_get_retry,	/* SIOCGIWRETRY */
 	(iw_handler) prism54_set_encode,	/* SIOCSIWENCODE */
diff -uNr prism54.orig/ksrc/islpci_dev.h prism54/ksrc/islpci_dev.h
--- prism54.orig/ksrc/islpci_dev.h	2003-12-17 08:16:39.000000000 +0200
+++ prism54/ksrc/islpci_dev.h	2003-12-19 10:19:55.000000000 +0200
@@ -85,6 +85,7 @@
 	volatile u32 shortretries;
 	volatile u32 longretries;
 	volatile u32 maxtxlifetime;
+	volatile u32 fixedtxpower;
 
 	struct semaphore sem;
 };
diff -uNr prism54.orig/ksrc/islpci_mgt.h prism54/ksrc/islpci_mgt.h
--- prism54.orig/ksrc/islpci_mgt.h	2003-12-17 08:16:39.000000000 +0200
+++ prism54/ksrc/islpci_mgt.h	2003-12-19 13:59:17.000000000 +0200
@@ -79,6 +79,8 @@
 #define OID_INL_COMPONENT_ID                    0xFF020007
 #define OID_INL_CONFIG                          0xFF020008
 #define OID_INL_DOT11D_CONFORMANCE              0xFF02000C
+#define	OID_INL_OUTPUTPOWER 					0xFF02000F
+
 
 /* The dot11d conformance level configures the 802.11d conformance
levels.
  * The following conformance levels exist:*/