Skip to contentSkip to conversation

gspca_cpia1: Disable illuminator controls if not an Intel Play QX3

PATCH Superseded Andy Walls 3 participants 3 messages Sep 12, 2010 Media (V4L/DVB)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Andy Walls

author
#0 lore raw

PATCH 2/3 gspca_cpia1: Disable illuminator controls if not an Intel Play QX3

gspca_cpia1: Disable illuminator controls if not an Intel Play QX3

The illuminator controls should only be available to the user for the Intel Play QX3 microscope.

linux/drivers/media/video/gspca/cpia1.c +19 -0
diff -r d165649ca8a0 -r 32d5c323c541 linux/drivers/media/video/gspca/cpia1.c
@@ -1743,6 +1743,22 @@
 	do_command(gspca_dev, CPIA_COMMAND_GetCameraStatus, 0, 0, 0, 0);
 }
 
+static void sd_disable_qx3_ctrls(struct gspca_dev *gspca_dev)
+{
+	int i, n;
+	__u32 id;
+
+	n = ARRAY_SIZE(sd_ctrls);
+	for (i = 0; i < n; i++) {
+		id = sd_ctrls[i].qctrl.id;
+
+		if (id == V4L2_CID_ILLUMINATORS_1 ||
+		    id == V4L2_CID_ILLUMINATORS_2) {
+			gspca_dev->ctrl_dis |= (1 << i);
+		}
+	}
+}
+
 /* this function is called at probe and resume time */
 static int sd_init(struct gspca_dev *gspca_dev)
 {
@@ -1758,6 +1774,9 @@
 
 	sd_stopN(gspca_dev);
 
+	if (!sd->params.qx3.qx3_detected)
+		sd_disable_qx3_ctrls(gspca_dev);
+
 	PDEBUG(D_PROBE, "CPIA Version:             %d.%02d (%d.%d)",
 			sd->params.version.firmwareVersion,
 			sd->params.version.firmwareRevision,
#1 lore raw

Hi,

Quoted 23 lines · Andy Walls

gspca_cpia1: Disable illuminator controls if not an Intel Play QX3

The illuminator controls should only be available to the user for the Intel Play QX3 microscope.

diff -r d165649ca8a0 -r 32d5c323c541 linux/drivers/media/video/gspca/cpia1.c

linux/drivers/media/video/gspca/cpia1.c +9 -0
@@ -1743,6 +1743,22 @@
  	do_command(gspca_dev, CPIA_COMMAND_GetCameraStatus, 0, 0, 0, 0);
  }
 
+static void sd_disable_qx3_ctrls(struct gspca_dev *gspca_dev)
+{
+	int i, n;
+	__u32 id;
+
+	n = ARRAY_SIZE(sd_ctrls);
+	for (i = 0; i<  n; i++) {
+		id = sd_ctrls[i].qctrl.id;
+

linux/drivers/media/video/gspca/cpia1.c line 1764

Quoted 10 lines
linux/drivers/media/video/gspca/cpia1.c +7 -0
+		if (id == V4L2_CID_ILLUMINATORS_1 ||
+		    id == V4L2_CID_ILLUMINATORS_2) {
+			gspca_dev->ctrl_dis |= (1<<  i);
+		}
+	}
+}
+
  /* this function is called at probe and resume time */
  static int sd_init(struct gspca_dev *gspca_dev)
  {

Hmm, this deviates from how all other gspca subdrivers do this, they define indexes for ctrls together with the sd_ctrls intializer and then use these, so instead of the above blurb there would be a

#define ILLUMINATORS_1_IDX x
#define ILLUMINATORS_2_IDX x

Where these ctrls get "defined" (see for example ov519.c)

And then:

linux/drivers/media/video/gspca/cpia1.c line 1779

Quoted 3 lines
linux/drivers/media/video/gspca/cpia1.c +3 -0
+	if (!sd->params.qx3.qx3_detected)
+		sd_disable_qx3_ctrls(gspca_dev);
+

Would become:

	if (!sd->params.qx3.qx3_detected)
		gspca_dev->ctrl_dis |= (1 << ILLUMINATORS_1_IDX) |
				       (1 << ILLUMINATORS_2_IDX);

I think it would be good to use the same construction in the cpia1 driver for consistency between all the gspca subdrivers.

Regards,

Hans

#2 lore raw
Quoted 55 lines · On Sunday, September 12, 2010 09:26:24 Hans de Goede wrote:

Hi,

Quoted 23 lines · Andy Walls

gspca_cpia1: Disable illuminator controls if not an Intel Play QX3

The illuminator controls should only be available to the user for the Intel Play QX3 microscope.

diff -r d165649ca8a0 -r 32d5c323c541 linux/drivers/media/video/gspca/cpia1.c

linux/drivers/media/video/gspca/cpia1.c +9 -0
@@ -1743,6 +1743,22 @@
  	do_command(gspca_dev, CPIA_COMMAND_GetCameraStatus, 0, 0, 0, 0);
  }
 
+static void sd_disable_qx3_ctrls(struct gspca_dev *gspca_dev)
+{
+	int i, n;
+	__u32 id;
+
+	n = ARRAY_SIZE(sd_ctrls);
+	for (i = 0; i<  n; i++) {
+		id = sd_ctrls[i].qctrl.id;
+

linux/drivers/media/video/gspca/cpia1.c line 1764

Quoted 10 lines
linux/drivers/media/video/gspca/cpia1.c +7 -0
+		if (id == V4L2_CID_ILLUMINATORS_1 ||
+		    id == V4L2_CID_ILLUMINATORS_2) {
+			gspca_dev->ctrl_dis |= (1<<  i);
+		}
+	}
+}
+
  /* this function is called at probe and resume time */
  static int sd_init(struct gspca_dev *gspca_dev)
  {

Hmm, this deviates from how all other gspca subdrivers do this, they define indexes for ctrls together with the sd_ctrls intializer and then use these, so instead of the above blurb there would be a

#define ILLUMINATORS_1_IDX x
#define ILLUMINATORS_2_IDX x

Where these ctrls get "defined" (see for example ov519.c)

And then:

linux/drivers/media/video/gspca/cpia1.c line 1779

Quoted 3 lines
linux/drivers/media/video/gspca/cpia1.c +3 -0
+	if (!sd->params.qx3.qx3_detected)
+		sd_disable_qx3_ctrls(gspca_dev);
+

Would become:

Quoted 6 lines
	if (!sd->params.qx3.qx3_detected)
		gspca_dev->ctrl_dis |= (1 << ILLUMINATORS_1_IDX) |
				       (1 << ILLUMINATORS_2_IDX);

I think it would be good to use the same construction in the cpia1 driver for consistency between all the gspca subdrivers.

Slightly off-topic: it would be nice if someone would look into converting gspca to the new control framework. I strongly suspect that that would simplify control handling in gspca.

Regards,

Hans

Signature · 1 line
Hans Verkuil - video4linux developer - sponsored by TANDBERG, part of Cisco