From: Jean-François Moine Date: Thu, 10 Feb 2011 10:01:30 +0000 (-0300) Subject: [media] gspca - sonixj: Move the avg lum computation to a separate function X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;h=0f77f40c300c18c15e7aeb2f9eee510aa96d58fd;p=deliverable%2Flinux.git [media] gspca - sonixj: Move the avg lum computation to a separate function Signed-off-by: Jean-François Moine Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/video/gspca/sonixj.c b/drivers/media/video/gspca/sonixj.c index d6f39ce1b7e1..c4147072b73e 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,