Skip to contentSkip to conversation

rtl28xxu: fix switch-case style issue

PATCH New Antti Palosaari 1 participant 9 messages Feb 5, 2014

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/9 rtl28xxu: fix switch-case style issue

Use break, not return, for every case.

---
 drivers/media/usb/dvb-usb-v2/rtl28xxu.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/media/usb/dvb-usb-v2/rtl28xxu.c +1 -2
index 73348bf..afafe92 100644
@@ -906,7 +906,6 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap)
 		/* attach SDR */
 		dvb_attach(rtl2832_sdr_attach, adap->fe[0], &d->i2c_adap,
 				&rtl28xxu_rtl2832_fc0012_config);
-		return 0;
 		break;
 	case TUNER_RTL2832_FC0013:
 		fe = dvb_attach(fc0013_attach, adap->fe[0],
@@ -919,7 +918,7 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap)
 		/* attach SDR */
 		dvb_attach(rtl2832_sdr_attach, adap->fe[0], &d->i2c_adap,
 				&rtl28xxu_rtl2832_fc0013_config);
-		return 0;
+		break;
 	case TUNER_RTL2832_E4000: {
 			struct e4000_config e4000_config = {
 				.fe = adap->fe[0],
Signature · 1 line
1.8.5.3
#1 lore raw

PATCH 2/9 v4l: reorganize RF tuner control ID numbers

It appears that controls are ordered by ID number. Change order of controls by reorganizing assigned IDs now as we can. It is not reasonable possible after the API is released. Leave some spare space between IDs too for future extensions.

---
 include/uapi/linux/v4l2-controls.h | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
include/uapi/linux/v4l2-controls.h +8 -8
index 3cf68a6..cc488c3 100644
@@ -899,13 +899,13 @@ enum v4l2_deemphasis {
 #define V4L2_CID_RF_TUNER_CLASS_BASE		(V4L2_CTRL_CLASS_RF_TUNER | 0x900)
 #define V4L2_CID_RF_TUNER_CLASS			(V4L2_CTRL_CLASS_RF_TUNER | 1)
 
-#define V4L2_CID_LNA_GAIN_AUTO			(V4L2_CID_RF_TUNER_CLASS_BASE + 1)
-#define V4L2_CID_LNA_GAIN			(V4L2_CID_RF_TUNER_CLASS_BASE + 2)
-#define V4L2_CID_MIXER_GAIN_AUTO		(V4L2_CID_RF_TUNER_CLASS_BASE + 3)
-#define V4L2_CID_MIXER_GAIN			(V4L2_CID_RF_TUNER_CLASS_BASE + 4)
-#define V4L2_CID_IF_GAIN_AUTO			(V4L2_CID_RF_TUNER_CLASS_BASE + 5)
-#define V4L2_CID_IF_GAIN			(V4L2_CID_RF_TUNER_CLASS_BASE + 6)
-#define V4L2_CID_BANDWIDTH_AUTO			(V4L2_CID_RF_TUNER_CLASS_BASE + 7)
-#define V4L2_CID_BANDWIDTH			(V4L2_CID_RF_TUNER_CLASS_BASE + 8)
+#define V4L2_CID_BANDWIDTH_AUTO			(V4L2_CID_RF_TUNER_CLASS_BASE + 11)
+#define V4L2_CID_BANDWIDTH			(V4L2_CID_RF_TUNER_CLASS_BASE + 12)
+#define V4L2_CID_LNA_GAIN_AUTO			(V4L2_CID_RF_TUNER_CLASS_BASE + 41)
+#define V4L2_CID_LNA_GAIN			(V4L2_CID_RF_TUNER_CLASS_BASE + 42)
+#define V4L2_CID_MIXER_GAIN_AUTO		(V4L2_CID_RF_TUNER_CLASS_BASE + 51)
+#define V4L2_CID_MIXER_GAIN			(V4L2_CID_RF_TUNER_CLASS_BASE + 52)
+#define V4L2_CID_IF_GAIN_AUTO			(V4L2_CID_RF_TUNER_CLASS_BASE + 61)
+#define V4L2_CID_IF_GAIN			(V4L2_CID_RF_TUNER_CLASS_BASE + 62)
 
 #endif
Signature · 1 line
1.8.5.3
#2 lore raw

PATCH 3/9 DocBook: document RF tuner bandwidth controls

In reply to Antti Palosaari

Add documentation for RF tuner bandwidth controls. These controls are used to set filters on tuner signal path.

---
 Documentation/DocBook/media/v4l/controls.xml | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
Documentation/DocBook/media/v4l/controls.xml +19 -0
index 0145341..345b6e5 100644
@@ -5007,6 +5007,25 @@ descriptor. Calling &VIDIOC-QUERYCTRL; for this control will return a
 description of this control class.</entry>
             </row>
             <row>
+              <entry spanname="id"><constant>V4L2_CID_BANDWIDTH_AUTO</constant>&nbsp;</entry>
+              <entry>boolean</entry>
+            </row>
+            <row>
+              <entry spanname="descr">Enables/disables tuner radio channel
+bandwidth configuration. In automatic mode bandwidth configuration is performed
+by the driver.</entry>
+            </row>
+            <row>
+              <entry spanname="id"><constant>V4L2_CID_BANDWIDTH</constant>&nbsp;</entry>
+              <entry>integer</entry>
+            </row>
+            <row>
+              <entry spanname="descr">Filter(s) on tuner signal path are used to
+filter signal according to receiving party needs. Driver configures filters to
+fulfill desired bandwidth requirement. Used when V4L2_CID_BANDWIDTH_AUTO is not
+set. The range and step are driver-specific.</entry>
+            </row>
+            <row>
               <entry spanname="id"><constant>V4L2_CID_LNA_GAIN_AUTO</constant>&nbsp;</entry>
               <entry>boolean</entry>
             </row>
Signature · 1 line
1.8.5.3
#3 lore raw

PATCH 4/9 v4l: uapi: add SDR formats CU8 and CU16LE

In reply to Antti Palosaari

V4L2_SDR_FMT_CU8 — Complex unsigned 8-bit IQ sample V4L2_SDR_FMT_CU16LE — Complex unsigned 16-bit little endian IQ sample

---
 include/uapi/linux/videodev2.h | 4 ++++
 1 file changed, 4 insertions(+)
include/uapi/linux/videodev2.h +4 -0
index 27fedfe..3411215 100644
@@ -436,6 +436,10 @@ struct v4l2_pix_format {
 #define V4L2_PIX_FMT_SE401      v4l2_fourcc('S', '4', '0', '1') /* se401 janggu compressed rgb */
 #define V4L2_PIX_FMT_S5C_UYVY_JPG v4l2_fourcc('S', '5', 'C', 'I') /* S5C73M3 interleaved UYVY/JPEG */
 
+/* SDR formats - used only for Software Defined Radio devices */
+#define V4L2_SDR_FMT_CU8          v4l2_fourcc('C', 'U', '0', '8') /* IQ u8 */
+#define V4L2_SDR_FMT_CU16LE       v4l2_fourcc('C', 'U', '1', '6') /* IQ u16le */
+
 /*
  *	F O R M A T   E N U M E R A T I O N
  */
Signature · 1 line
1.8.5.3
#4 lore raw

PATCH 5/9 msi3101: use formats defined in V4L2 API

In reply to Antti Palosaari

Switch new formats V4L2_SDR_FMT_CU8 and V4L2_SDR_FMT_CU16LE as those are now defined in API.

---
 drivers/staging/media/msi3101/sdr-msi3101.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)
drivers/staging/media/msi3101/sdr-msi3101.c +7 -9
index df1a3a1..36990cb 100644
@@ -52,8 +52,6 @@
 #define MAX_ISOC_ERRORS         20
 
 /* TODO: These should be moved to V4L2 API */
-#define V4L2_PIX_FMT_SDR_U8     v4l2_fourcc('D', 'U', '0', '8') /* unsigned 8-bit */
-#define V4L2_PIX_FMT_SDR_U16LE  v4l2_fourcc('D', 'U', '1', '6') /* unsigned 16-bit LE */
 #define V4L2_PIX_FMT_SDR_S8     v4l2_fourcc('D', 'S', '0', '8') /* signed 8-bit */
 #define V4L2_PIX_FMT_SDR_S12    v4l2_fourcc('D', 'S', '1', '2') /* signed 12-bit */
 #define V4L2_PIX_FMT_SDR_S14    v4l2_fourcc('D', 'S', '1', '4') /* signed 14-bit */
@@ -97,11 +95,11 @@ struct msi3101_format {
 /* format descriptions for capture and preview */
 static struct msi3101_format formats[] = {
 	{
-		.name		= "8-bit unsigned",
-		.pixelformat	= V4L2_PIX_FMT_SDR_U8,
+		.name		= "IQ U8",
+		.pixelformat	= V4L2_SDR_FMT_CU8,
 	}, {
-		.name		= "16-bit unsigned little endian",
-		.pixelformat	= V4L2_PIX_FMT_SDR_U16LE,
+		.name		= "IQ U16LE",
+		.pixelformat	=  V4L2_SDR_FMT_CU16LE,
 #if 0
 	}, {
 		.name		= "8-bit signed",
@@ -940,11 +938,11 @@ static int msi3101_set_usb_adc(struct msi3101_state *s)
 
 	/* select stream format */
 	switch (s->pixelformat) {
-	case V4L2_PIX_FMT_SDR_U8:
+	case V4L2_SDR_FMT_CU8:
 		s->convert_stream = msi3101_convert_stream_504_u8;
 		reg7 = 0x000c9407;
 		break;
-	case V4L2_PIX_FMT_SDR_U16LE:
+	case  V4L2_SDR_FMT_CU16LE:
 		s->convert_stream = msi3101_convert_stream_252_u16;
 		reg7 = 0x00009407;
 		break;
@@ -1416,7 +1414,7 @@ static int msi3101_probe(struct usb_interface *intf,
 	INIT_LIST_HEAD(&s->queued_bufs);
 	s->udev = udev;
 	s->f_adc = bands_adc[0].rangelow;
-	s->pixelformat = V4L2_PIX_FMT_SDR_U8;
+	s->pixelformat = V4L2_SDR_FMT_CU8;
 
 	/* Init videobuf2 queue structure */
 	s->vb_queue.type = V4L2_BUF_TYPE_SDR_CAPTURE;
Signature · 1 line
1.8.5.3
#5 lore raw

PATCH 6/9 rtl2832_sdr: use formats defined in V4L2 API

In reply to Antti Palosaari

Switch new formats V4L2_SDR_FMT_CU8 and V4L2_SDR_FMT_CU16LE as those are now defined in API.

---
 drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)
drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c +7 -11
index c26c084..e89abd8 100644
@@ -37,10 +37,6 @@
 #include <linux/jiffies.h>
 #include <linux/math64.h>
 
-/* TODO: These should be moved to V4L2 API */
-#define V4L2_PIX_FMT_SDR_U8    v4l2_fourcc('D', 'U', '0', '8')
-#define V4L2_PIX_FMT_SDR_U16LE v4l2_fourcc('D', 'U', '1', '6')
-
 #define MAX_BULK_BUFS            (10)
 #define BULK_BUFFER_SIZE         (128 * 512)
 
@@ -90,11 +86,11 @@ struct rtl2832_sdr_format {
 
 static struct rtl2832_sdr_format formats[] = {
 	{
-		.name		= "8-bit unsigned",
-		.pixelformat	= V4L2_PIX_FMT_SDR_U8,
+		.name		= "IQ U8",
+		.pixelformat	=  V4L2_SDR_FMT_CU8,
 	}, {
-		.name		= "16-bit unsigned little endian",
-		.pixelformat	= V4L2_PIX_FMT_SDR_U16LE,
+		.name		= "IQ U16LE (emulated)",
+		.pixelformat	= V4L2_SDR_FMT_CU16LE,
 	},
 };
 
@@ -346,11 +342,11 @@ static unsigned int rtl2832_sdr_convert_stream(struct rtl2832_sdr_state *s,
 {
 	unsigned int dst_len;
 
-	if (s->pixelformat == V4L2_PIX_FMT_SDR_U8) {
+	if (s->pixelformat ==  V4L2_SDR_FMT_CU8) {
 		/* native stream, no need to convert */
 		memcpy(dst, src, src_len);
 		dst_len = src_len;
-	} else if (s->pixelformat == V4L2_PIX_FMT_SDR_U16LE) {
+	} else if (s->pixelformat == V4L2_SDR_FMT_CU16LE) {
 		/* convert u8 to u16 */
 		unsigned int i;
 		u16 *u16dst = dst;
@@ -1410,7 +1406,7 @@ struct dvb_frontend *rtl2832_sdr_attach(struct dvb_frontend *fe,
 	s->i2c = i2c;
 	s->cfg = cfg;
 	s->f_adc = bands_adc[0].rangelow;
-	s->pixelformat = V4L2_PIX_FMT_SDR_U8;
+	s->pixelformat =  V4L2_SDR_FMT_CU8;
 
 	mutex_init(&s->v4l2_lock);
 	mutex_init(&s->vb_queue_lock);
Signature · 1 line
1.8.5.3
#6 lore raw

PATCH 7/9 v4l: add enum_freq_bands support to tuner sub-device

In reply to Antti Palosaari

Add VIDIOC_ENUM_FREQ_BANDS, enumerate supported frequency bands, IOCTL support for sub-device tuners too.

---
 include/media/v4l2-subdev.h | 1 +
 1 file changed, 1 insertion(+)
include/media/v4l2-subdev.h +1 -0
index d67210a..4682aad 100644
@@ -192,6 +192,7 @@ struct v4l2_subdev_tuner_ops {
 	int (*s_radio)(struct v4l2_subdev *sd);
 	int (*s_frequency)(struct v4l2_subdev *sd, const struct v4l2_frequency *freq);
 	int (*g_frequency)(struct v4l2_subdev *sd, struct v4l2_frequency *freq);
+	int (*enum_freq_bands)(struct v4l2_subdev *sd, struct v4l2_frequency_band *band);
 	int (*g_tuner)(struct v4l2_subdev *sd, struct v4l2_tuner *vt);
 	int (*s_tuner)(struct v4l2_subdev *sd, const struct v4l2_tuner *vt);
 	int (*g_modulator)(struct v4l2_subdev *sd, struct v4l2_modulator *vm);
Signature · 1 line
1.8.5.3
#7 lore raw

PATCH 8/9 msi001: implement .enum_freq_bands()

In reply to Antti Palosaari

Implement .enum_freq_bands() in order to provide
VIDIOC_ENUM_FREQ_BANDS IOCTL from sub-device.

---
 drivers/staging/media/msi3101/msi001.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/staging/media/msi3101/msi001.c +18 -0
index 9ccfd9b..6b586dc 100644
@@ -343,11 +343,29 @@ static int msi001_s_frequency(struct v4l2_subdev *sd,
 	return msi001_set_tuner(s);
 }
 
+static int msi001_enum_freq_bands(struct v4l2_subdev *sd,
+		struct v4l2_frequency_band *band)
+{
+	struct msi001 *s = sd_to_msi001(sd);
+	dev_dbg(&s->spi->dev, "%s: tuner=%d type=%d index=%d\n",
+			__func__, band->tuner, band->type, band->index);
+
+	if (band->index >= ARRAY_SIZE(bands))
+		return -EINVAL;
+
+	band->capability = bands[band->index].capability;
+	band->rangelow = bands[band->index].rangelow;
+	band->rangehigh = bands[band->index].rangehigh;
+
+	return 0;
+}
+
 static const struct v4l2_subdev_tuner_ops msi001_tuner_ops = {
 	.g_tuner                  = msi001_g_tuner,
 	.s_tuner                  = msi001_s_tuner,
 	.g_frequency              = msi001_g_frequency,
 	.s_frequency              = msi001_s_frequency,
+	.enum_freq_bands          = msi001_enum_freq_bands,
 };
 
 static const struct v4l2_subdev_ops msi001_ops = {
Signature · 1 line
1.8.5.3
#8 lore raw

PATCH 9/9 msi3101: provide RF tuner bands from sub-device

In reply to Antti Palosaari

Let the msi001 tuner driver report its frequency bands.

---
 drivers/staging/media/msi3101/sdr-msi3101.c | 48 +++++++++--------------------
 1 file changed, 15 insertions(+), 33 deletions(-)
drivers/staging/media/msi3101/sdr-msi3101.c +15 -33
index 36990cb..6bd7b67 100644
@@ -57,7 +57,7 @@
 #define V4L2_PIX_FMT_SDR_S14    v4l2_fourcc('D', 'S', '1', '4') /* signed 14-bit */
 #define V4L2_PIX_FMT_SDR_MSI2500_384 v4l2_fourcc('M', '3', '8', '4') /* Mirics MSi2500 format 384 */
 
-static const struct v4l2_frequency_band bands_adc[] = {
+static const struct v4l2_frequency_band bands[] = {
 	{
 		.tuner = 0,
 		.type = V4L2_TUNER_ADC,
@@ -68,24 +68,6 @@ static const struct v4l2_frequency_band bands_adc[] = {
 	},
 };
 
-static const struct v4l2_frequency_band bands_rf[] = {
-	{
-		.tuner = 1,
-		.type = V4L2_TUNER_RF,
-		.index = 0,
-		.capability = V4L2_TUNER_CAP_1HZ | V4L2_TUNER_CAP_FREQ_BANDS,
-		.rangelow   =   49000000,
-		.rangehigh  =  263000000,
-	}, {
-		.tuner = 1,
-		.type = V4L2_TUNER_RF,
-		.index = 1,
-		.capability = V4L2_TUNER_CAP_1HZ | V4L2_TUNER_CAP_FREQ_BANDS,
-		.rangelow   =  390000000,
-		.rangehigh  =  960000000,
-	},
-};
-
 /* stream formats */
 struct msi3101_format {
 	char	*name;
@@ -1268,8 +1250,8 @@ static int msi3101_s_frequency(struct file *file, void *priv,
 
 	if (f->tuner == 0) {
 		s->f_adc = clamp_t(unsigned int, f->frequency,
-				bands_adc[0].rangelow,
-				bands_adc[0].rangehigh);
+				bands[0].rangelow,
+				bands[0].rangehigh);
 		dev_dbg(&s->udev->dev, "%s: ADC frequency=%u Hz\n",
 				__func__, s->f_adc);
 		ret = msi3101_set_usb_adc(s);
@@ -1286,25 +1268,25 @@ static int msi3101_enum_freq_bands(struct file *file, void *priv,
 		struct v4l2_frequency_band *band)
 {
 	struct msi3101_state *s = video_drvdata(file);
+	int ret;
 	dev_dbg(&s->udev->dev, "%s: tuner=%d type=%d index=%d\n",
 			__func__, band->tuner, band->type, band->index);
 
 	if (band->tuner == 0) {
-		if (band->index >= ARRAY_SIZE(bands_adc))
-			return -EINVAL;
-
-		*band = bands_adc[band->index];
+		if (band->index >= ARRAY_SIZE(bands)) {
+			ret = -EINVAL;
+		} else {
+			*band = bands[band->index];
+			ret = 0;
+		}
 	} else if (band->tuner == 1) {
-		/* TODO: add that to v4l2_subdev_tuner_ops */
-		if (band->index >= ARRAY_SIZE(bands_rf))
-			return -EINVAL;
-
-		*band = bands_rf[band->index];
+		ret = v4l2_subdev_call(s->v4l2_subdev, tuner,
+				enum_freq_bands, band);
 	} else {
-		return -EINVAL;
+		ret = -EINVAL;
 	}
 
-	return 0;
+	return ret;
 }
 
 static const struct v4l2_ioctl_ops msi3101_ioctl_ops = {
@@ -1413,7 +1395,7 @@ static int msi3101_probe(struct usb_interface *intf,
 	spin_lock_init(&s->queued_bufs_lock);
 	INIT_LIST_HEAD(&s->queued_bufs);
 	s->udev = udev;
-	s->f_adc = bands_adc[0].rangelow;
+	s->f_adc = bands[0].rangelow;
 	s->pixelformat = V4L2_SDR_FMT_CU8;
 
 	/* Init videobuf2 queue structure */
Signature · 1 line
1.8.5.3