summaryrefslogtreecommitdiffstats
path: root/drivers/media/video/gspca/sonixj.c
diff options
context:
space:
mode:
authorJean-François Moine <moinejf@free.fr>2011-02-10 07:01:30 -0300
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-03-21 20:32:05 -0300
commit0f77f40c300c18c15e7aeb2f9eee510aa96d58fd (patch)
tree4093458ebadeb2e1b1b25dde80da1514248328b0 /drivers/media/video/gspca/sonixj.c
parentd39155d91d034e2b2c9154892e29c8a8eb193b7f (diff)
[media] gspca - sonixj: Move the avg lum computation to a separate function
Signed-off-by: Jean-François Moine <moinejf@free.fr> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/gspca/sonixj.c')
-rw-r--r--drivers/media/video/gspca/sonixj.c44
1 files changed, 26 insertions, 18 deletions
diff --git a/drivers/media/video/gspca/sonixj.c b/drivers/media/video/gspca/sonixj.c
index d6f39ce1b7e..c4147072b73 100644
--- a/drivers/media/video/gspca/sonixj.c
+++ b/drivers/media/video/gspca/sonixj.c
@@ -2757,6 +2757,29 @@ static void do_autogain(struct gspca_dev *gspca_dev)
}
}
+/* set the average luminosity from an isoc marker */
+static void set_lum(struct sd *sd,
+ u8 *data)
+{
+ int avg_lum;
+
+ /* w0 w1 w2
+ * w3 w4 w5
+ * w6 w7 w8
+ */
+ avg_lum = (data[27] << 8) + data[28] /* w3 */
+
+ + (data[31] << 8) + data[32] /* w5 */
+
+ + (data[23] << 8) + data[24] /* w1 */
+
+ + (data[35] << 8) + data[36] /* w7 */
+
+ + (data[29] << 10) + (data[30] << 2); /* w4 * 4 */
+ avg_lum >>= 10;
+ atomic_set(&sd->avg_lum, avg_lum);
+}
+
/* scan the URB packets */
/* This function is run at interrupt level. */
static void sd_pkt_scan(struct gspca_dev *gspca_dev,
@@ -2764,7 +2787,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
int len) /* iso packet length */
{
struct sd *sd = (struct sd *) gspca_dev;
- int sof, avg_lum;
+ int sof;
/* the image ends on a 64 bytes block starting with
* ff d9 ff ff 00 c4 c4 96
@@ -2795,23 +2818,8 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
/* end of image found - remove the trailing data */
gspca_dev->image_len = sof + 2;
gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0);
- if (sd->ag_cnt < 0)
- return;
-/* w1 w2 w3 */
-/* w4 w5 w6 */
-/* w7 w8 */
-/* w4 */
- avg_lum = ((data[sof + 29] << 8) | data[sof + 30]) >> 6;
-/* w6 */
- avg_lum += ((data[sof + 33] << 8) | data[sof + 34]) >> 6;
-/* w2 */
- avg_lum += ((data[sof + 25] << 8) | data[sof + 26]) >> 6;
-/* w8 */
- avg_lum += ((data[sof + 37] << 8) | data[sof + 38]) >> 6;
-/* w5 */
- avg_lum += ((data[sof + 31] << 8) | data[sof + 32]) >> 4;
- avg_lum >>= 4;
- atomic_set(&sd->avg_lum, avg_lum);
+ if (sd->ag_cnt >= 0)
+ set_lum(sd, data + sof + 2);
}
static int sd_set_jcomp(struct gspca_dev *gspca_dev,