[GIT,PATCHES,FOR,3.4] gspca for_v3.4

Message ID 20120310123901.72aaa060@tele (mailing list archive)
State Accepted, archived
Headers

Commit Message

Jean-Francois Moine March 10, 2012, 11:39 a.m. UTC
  On Tue, 28 Feb 2012 12:15:43 +0100
Sylwester Nawrocki <s.nawrocki@samsung.com> wrote:

> > I checked the changes in zc3xx.c, and I have made many commits. So, it
> > would be simpler if you would remove your patch. I could give you a
> > merged one once the media tree would be updated.  
> 
> OK, if it's easier please carry the patch in your tree. Otherwise, let me
> handle it after our pull request are included in the media tree.

Hi Sylwester,

Here is the merge of your patch (origin media_tree staging/for_v3.4).
As I have an other patch to do to the driver, I may add it to my
changes once you have acked it (I have no webcam to test it).

Best regards.
  

Comments

Sylwester Nawrocki March 10, 2012, 7:24 p.m. UTC | #1
On 03/10/2012 12:39 PM, Jean-Francois Moine wrote:
> On Tue, 28 Feb 2012 12:15:43 +0100
> Sylwester Nawrocki<s.nawrocki@samsung.com>  wrote:
> 
>>> I checked the changes in zc3xx.c, and I have made many commits. So, it
>>> would be simpler if you would remove your patch. I could give you a
>>> merged one once the media tree would be updated.
>>
>> OK, if it's easier please carry the patch in your tree. Otherwise, let me
>> handle it after our pull request are included in the media tree.
> 
> Hi Sylwester,
> 
> Here is the merge of your patch (origin media_tree staging/for_v3.4).
> As I have an other patch to do to the driver, I may add it to my
> changes once you have acked it (I have no webcam to test it).

Hi Jean-Francois,

thanks, I have tested your patch, but on the webcam I have (A4TECH PK-835):

[16803.614071] usb 2-1.1: new full speed USB device using ehci_hcd and address 10
[16803.708177] gspca: probing 0ac8:303b
[16804.634470] zc3xx: probe 2wr ov vga 0x0000
[16804.658594] zc3xx: probe sensor -> 0011
[16804.658601] zc3xx: Find Sensor HV7131R
[16804.659099] input: zc3xx as /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.1/input/input13
[16804.659512] gspca: video1 created

the JPEG quality control is disabled. I have removed the following line from 
the patch temporarily:

 +		gspca_dev->ctrl_dis = (1 << QUALITY);

just to see if it appears. Of course due to the automatic transfer control
introduced with patches starting from
http://git.linuxtv.org/media_tree.git/commit/30c73d464a10bee4bb8375bb2ed8cc102c507bb7
the jpeg quality control doesn't do anything useful. 

So I can't really test the patch, but it looks fine for me. And if it's needed
please include it in your other change set. FWIW,

Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com>

--
Regards,
Sylwester
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
  

Patch

diff --git a/drivers/media/video/gspca/zc3xx.c b/drivers/media/video/gspca/zc3xx.c
index c10bdb4..7bbdf83 100644
--- a/drivers/media/video/gspca/zc3xx.c
+++ b/drivers/media/video/gspca/zc3xx.c
@@ -44,6 +44,7 @@  enum e_ctrl {
 	AUTOGAIN,
 	LIGHTFREQ,
 	SHARPNESS,
+	QUALITY,
 	NCTRLS		/* number of controls */
 };
 
@@ -99,6 +100,7 @@  static void setexposure(struct gspca_dev *gspca_dev);
 static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val);
 static void setlightfreq(struct gspca_dev *gspca_dev);
 static void setsharpness(struct gspca_dev *gspca_dev);
+static int sd_setquality(struct gspca_dev *gspca_dev, __s32 val);
 
 static const struct ctrl sd_ctrls[NCTRLS] = {
 [BRIGHTNESS] = {
@@ -186,6 +188,18 @@  static const struct ctrl sd_ctrls[NCTRLS] = {
 	    },
 	    .set_control = setsharpness
 	},
+[QUALITY] = {
+	    {
+		.id	 = V4L2_CID_JPEG_COMPRESSION_QUALITY,
+		.type    = V4L2_CTRL_TYPE_INTEGER,
+		.name    = "Compression Quality",
+		.minimum = 40,
+		.maximum = 70,
+		.step    = 1,
+		.default_value = 70	/* updated in sd_init() */
+	    },
+	    .set = sd_setquality
+	},
 };
 
 static const struct v4l2_pix_format vga_mode[] = {
@@ -6151,6 +6165,7 @@  static void transfer_update(struct work_struct *work)
 				 || !gspca_dev->present
 				 || !gspca_dev->streaming)
 					goto err;
+				sd->ctrls[QUALITY].val = jpeg_qual[sd->reg08];
 				jpeg_set_qual(sd->jpeg_hdr,
 						jpeg_qual[sd->reg08]);
 			}
@@ -6717,13 +6732,20 @@  static int sd_init(struct gspca_dev *gspca_dev)
 
 	sd->ctrls[GAMMA].def = gamma[sd->sensor];
 	sd->reg08 = reg08_tb[sd->sensor];
+	sd->ctrls[QUALITY].def = jpeg_qual[sd->reg08];
+	sd->ctrls[QUALITY].min = jpeg_qual[0];
+	sd->ctrls[QUALITY].max = jpeg_qual[ARRAY_SIZE(jpeg_qual) - 1];
 
 	switch (sd->sensor) {
 	case SENSOR_HV7131R:
+		gspca_dev->ctrl_dis = (1 << QUALITY);
 		break;
 	case SENSOR_OV7630C:
 		gspca_dev->ctrl_dis = (1 << LIGHTFREQ) | (1 << EXPOSURE);
 		break;
+	case SENSOR_PAS202B:
+		gspca_dev->ctrl_dis = (1 << QUALITY) | (1 << EXPOSURE);
+		break;
 	default:
 		gspca_dev->ctrl_dis = (1 << EXPOSURE);
 		break;
@@ -7003,24 +7025,33 @@  static int sd_querymenu(struct gspca_dev *gspca_dev,
 	return -EINVAL;
 }
 
-static int sd_set_jcomp(struct gspca_dev *gspca_dev,
-			struct v4l2_jpegcompression *jcomp)
+static int sd_setquality(struct gspca_dev *gspca_dev, __s32 val)
 {
 	struct sd *sd = (struct sd *) gspca_dev;
 	int i;
 
 	for (i = 0; i < ARRAY_SIZE(jpeg_qual) - 1; i++) {
-		if (jcomp->quality <= jpeg_qual[i])
+		if (val <= jpeg_qual[i])
 			break;
 	}
 	if (i > 0
 	 && i == sd->reg08
-	 && jcomp->quality < jpeg_qual[sd->reg08])
+	 && val < jpeg_qual[sd->reg08])
 		i--;
 	sd->reg08 = i;
-	jcomp->quality = jpeg_qual[i];
+	sd->ctrls[QUALITY].val = jpeg_qual[i];
 	if (gspca_dev->streaming)
-		jpeg_set_qual(sd->jpeg_hdr, jcomp->quality);
+		jpeg_set_qual(sd->jpeg_hdr, sd->ctrls[QUALITY].val);
+	return gspca_dev->usb_err;
+}
+
+static int sd_set_jcomp(struct gspca_dev *gspca_dev,
+			struct v4l2_jpegcompression *jcomp)
+{
+	struct sd *sd = (struct sd *) gspca_dev;
+
+	sd_setquality(gspca_dev, jcomp->quality);
+	jcomp->quality = sd->ctrls[QUALITY].val;
 	return gspca_dev->usb_err;
 }
 
@@ -7030,7 +7061,7 @@  static int sd_get_jcomp(struct gspca_dev *gspca_dev,
 	struct sd *sd = (struct sd *) gspca_dev;
 
 	memset(jcomp, 0, sizeof *jcomp);
-	jcomp->quality = jpeg_qual[sd->reg08];
+	jcomp->quality = sd->ctrls[QUALITY].val;
 	jcomp->jpeg_markers = V4L2_JPEG_MARKER_DHT
 			| V4L2_JPEG_MARKER_DQT;
 	return 0;