diff options
author | Leandro Costantino <lcostantino@gmail.com> | 2008-10-17 04:27:04 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2008-10-17 16:41:14 -0400 |
commit | ad62fb08dee8d56f79add53befe9e07c8cec0a95 (patch) | |
tree | 2d6ea39d07ba0b46c7542435aac52a7606008821 /drivers/media/video/gspca/t613.c | |
parent | 35480b6bc3884a1c2f9928c45c67dbfe85e1de75 (diff) |
V4L/DVB (9293): gspca: Separate and fix the sensor dependant sequences in t613.
Signed-off-by: Leandro Costantino <lcostantino@gmail.com>
Signed-off-by: Jean-Francois Moine <moinejf@free.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/gspca/t613.c')
-rw-r--r-- | drivers/media/video/gspca/t613.c | 147 |
1 files changed, 110 insertions, 37 deletions
diff --git a/drivers/media/video/gspca/t613.c b/drivers/media/video/gspca/t613.c index 3ffbf37e946d..b2823700bd93 100644 --- a/drivers/media/video/gspca/t613.c +++ b/drivers/media/video/gspca/t613.c | |||
@@ -261,6 +261,59 @@ static struct v4l2_pix_format vga_mode_t16[] = { | |||
261 | .priv = 0}, | 261 | .priv = 0}, |
262 | }; | 262 | }; |
263 | 263 | ||
264 | /* sensor specific data */ | ||
265 | struct additional_sensor_data { | ||
266 | const __u8 data1[20]; | ||
267 | const __u8 data2[18]; | ||
268 | const __u8 data3[18]; | ||
269 | const __u8 data4[4]; | ||
270 | const __u8 data5[6]; | ||
271 | const __u8 stream[4]; | ||
272 | }; | ||
273 | |||
274 | const static struct additional_sensor_data sensor_data[] = { | ||
275 | { /* TAS5130A */ | ||
276 | .data1 = | ||
277 | {0xd0, 0xbb, 0xd1, 0x28, 0xd2, 0x10, 0xd3, 0x10, | ||
278 | 0xd4, 0xbb, 0xd5, 0x28, 0xd6, 0x1e, 0xd7, 0x27, | ||
279 | 0xd8, 0xc8, 0xd9, 0xfc}, | ||
280 | .data2 = | ||
281 | {0xe0, 0x60, 0xe1, 0xa8, 0xe2, 0xe0, 0xe3, 0x60, | ||
282 | 0xe4, 0xa8, 0xe5, 0xe0, 0xe6, 0x60, 0xe7, 0xa8, | ||
283 | 0xe8, 0xe0}, | ||
284 | .data3 = | ||
285 | {0xc7, 0x60, 0xc8, 0xa8, 0xc9, 0xe0, 0xca, 0x60, | ||
286 | 0xcb, 0xa8, 0xcc, 0xe0, 0xcd, 0x60, 0xce, 0xa8, | ||
287 | 0xcf, 0xe0}, | ||
288 | .data4 = /* Freq (50/60Hz). Splitted for test purpose */ | ||
289 | {0x66, 0x00, 0xa8, 0xe8}, | ||
290 | .data5 = | ||
291 | {0x0c, 0x03, 0xab, 0x10, 0x81, 0x20}, | ||
292 | .stream = | ||
293 | {0x0b, 0x04, 0x0a, 0x40}, | ||
294 | }, | ||
295 | { /* OM6802 */ | ||
296 | .data1 = | ||
297 | {0xd0, 0xc2, 0xd1, 0x28, 0xd2, 0x0f, 0xd3, 0x22, | ||
298 | 0xd4, 0xcd, 0xd5, 0x27, 0xd6, 0x2c, 0xd7, 0x06, | ||
299 | 0xd8, 0xb3, 0xd9, 0xfc}, | ||
300 | .data2 = | ||
301 | {0xe0, 0x80, 0xe1, 0xff, 0xe2, 0xff, 0xe3, 0x80, | ||
302 | 0xe4, 0xff, 0xe5, 0xff, 0xe6, 0x80, 0xe7, 0xff, | ||
303 | 0xe8, 0xff}, | ||
304 | .data3 = | ||
305 | {0xc7, 0x80, 0xc8, 0xff, 0xc9, 0xff, 0xca, 0x80, | ||
306 | 0xcb, 0xff, 0xcc, 0xff, 0xcd, 0x80, 0xce, 0xff, | ||
307 | 0xcf, 0xff}, | ||
308 | .data4 = /*Freq (50/60Hz). Splitted for test purpose */ | ||
309 | {0x66, 0xca, 0xa8, 0xf0 }, | ||
310 | .data5 = /* this could be removed later */ | ||
311 | {0x0c, 0x03, 0xab, 0x13, 0x81, 0x23}, | ||
312 | .stream = | ||
313 | {0x0b, 0x04, 0x0a, 0x78}, | ||
314 | } | ||
315 | }; | ||
316 | |||
264 | #define MAX_EFFECTS 7 | 317 | #define MAX_EFFECTS 7 |
265 | /* easily done by soft, this table could be removed, | 318 | /* easily done by soft, this table could be removed, |
266 | * i keep it here just in case */ | 319 | * i keep it here just in case */ |
@@ -603,32 +656,10 @@ static int sd_init(struct gspca_dev *gspca_dev) | |||
603 | 0x65, 0x0a, 0xbb, 0x86, 0xaf, 0x58, 0xb0, 0x68, | 656 | 0x65, 0x0a, 0xbb, 0x86, 0xaf, 0x58, 0xb0, 0x68, |
604 | 0x87, 0x40, 0x89, 0x2b, 0x8d, 0xff, 0x83, 0x40, | 657 | 0x87, 0x40, 0x89, 0x2b, 0x8d, 0xff, 0x83, 0x40, |
605 | 0xac, 0x84, 0xad, 0x86, 0xaf, 0x46}; | 658 | 0xac, 0x84, 0xad, 0x86, 0xaf, 0x46}; |
606 | static const __u8 nset4[] = { | ||
607 | 0xe0, 0x60, 0xe1, 0xa8, 0xe2, 0xe0, 0xe3, 0x60, 0xe4, 0xa8, | ||
608 | 0xe5, 0xe0, 0xe6, 0x60, 0xe7, 0xa8, | ||
609 | 0xe8, 0xe0 | ||
610 | }; | ||
611 | /* ojo puede ser 0xe6 en vez de 0xe9 */ | ||
612 | static const __u8 nset2[] = { | ||
613 | 0xd0, 0xbb, 0xd1, 0x28, 0xd2, 0x10, 0xd3, 0x10, 0xd4, 0xbb, | ||
614 | 0xd5, 0x28, 0xd6, 0x1e, 0xd7, 0x27, | ||
615 | 0xd8, 0xc8, 0xd9, 0xfc | ||
616 | }; | ||
617 | static const __u8 nset3[] = { | ||
618 | 0xc7, 0x60, 0xc8, 0xa8, 0xc9, 0xe0, 0xca, 0x60, 0xcb, 0xa8, | ||
619 | 0xcc, 0xe0, 0xcd, 0x60, 0xce, 0xa8, | ||
620 | 0xcf, 0xe0 | ||
621 | }; | ||
622 | static const __u8 nset5[] = | ||
623 | { 0x8f, 0x24, 0xc3, 0x00 }; /* bright */ | ||
624 | static const __u8 nset7[4] = | ||
625 | { 0x66, 0xca, 0xa8, 0xf8 }; /* 50/60 Hz */ | ||
626 | static const __u8 nset9[4] = | 659 | static const __u8 nset9[4] = |
627 | { 0x0b, 0x04, 0x0a, 0x78 }; | 660 | { 0x0b, 0x04, 0x0a, 0x78 }; |
628 | static const __u8 nset8[6] = | 661 | static const __u8 nset8[6] = |
629 | { 0xa8, 0xf0, 0xc6, 0x88, 0xc0, 0x00 }; | 662 | { 0xa8, 0xf0, 0xc6, 0x88, 0xc0, 0x00 }; |
630 | static const __u8 nset10[6] = | ||
631 | { 0x0c, 0x03, 0xab, 0x10, 0x81, 0x20 }; | ||
632 | 663 | ||
633 | byte = reg_r(gspca_dev, 0x06); | 664 | byte = reg_r(gspca_dev, 0x06); |
634 | test_byte = reg_r(gspca_dev, 0x07); | 665 | test_byte = reg_r(gspca_dev, 0x07); |
@@ -672,13 +703,18 @@ static int sd_init(struct gspca_dev *gspca_dev) | |||
672 | reg_w_buf(gspca_dev, n4, sizeof n4); | 703 | reg_w_buf(gspca_dev, n4, sizeof n4); |
673 | reg_r(gspca_dev, 0x0080); | 704 | reg_r(gspca_dev, 0x0080); |
674 | reg_w(gspca_dev, 0x2c80); | 705 | reg_w(gspca_dev, 0x2c80); |
675 | reg_w_buf(gspca_dev, nset2, sizeof nset2); | 706 | |
676 | reg_w_buf(gspca_dev, nset3, sizeof nset3); | 707 | reg_w_buf(gspca_dev, sensor_data[sd->sensor].data1, |
677 | reg_w_buf(gspca_dev, nset4, sizeof nset4); | 708 | sizeof sensor_data[sd->sensor].data1); |
709 | reg_w_buf(gspca_dev, sensor_data[sd->sensor].data3, | ||
710 | sizeof sensor_data[sd->sensor].data3); | ||
711 | reg_w_buf(gspca_dev, sensor_data[sd->sensor].data2, | ||
712 | sizeof sensor_data[sd->sensor].data2); | ||
713 | |||
678 | reg_w(gspca_dev, 0x3880); | 714 | reg_w(gspca_dev, 0x3880); |
679 | reg_w(gspca_dev, 0x3880); | 715 | reg_w(gspca_dev, 0x3880); |
680 | reg_w(gspca_dev, 0x338e); | 716 | reg_w(gspca_dev, 0x338e); |
681 | nset5 - missing | 717 | |
682 | setbrightness(gspca_dev); | 718 | setbrightness(gspca_dev); |
683 | setcontrast(gspca_dev); | 719 | setcontrast(gspca_dev); |
684 | setgamma(gspca_dev); | 720 | setgamma(gspca_dev); |
@@ -690,15 +726,21 @@ nset5 - missing | |||
690 | reg_w(gspca_dev, 0x2088); | 726 | reg_w(gspca_dev, 0x2088); |
691 | reg_w(gspca_dev, 0x2089); | 727 | reg_w(gspca_dev, 0x2089); |
692 | 728 | ||
693 | reg_w_buf(gspca_dev, nset7, sizeof nset7); | 729 | reg_w_buf(gspca_dev, sensor_data[sd->sensor].data4, |
694 | reg_w_buf(gspca_dev, nset10, sizeof nset10); | 730 | sizeof sensor_data[sd->sensor].data4); |
731 | reg_w_buf(gspca_dev, sensor_data[sd->sensor].data5, | ||
732 | sizeof sensor_data[sd->sensor].data5); | ||
695 | reg_w_buf(gspca_dev, nset8, sizeof nset8); | 733 | reg_w_buf(gspca_dev, nset8, sizeof nset8); |
696 | reg_w_buf(gspca_dev, nset9, sizeof nset9); | 734 | reg_w_buf(gspca_dev, nset9, sizeof nset9); |
697 | 735 | ||
698 | reg_w(gspca_dev, 0x2880); | 736 | reg_w(gspca_dev, 0x2880); |
699 | reg_w_buf(gspca_dev, nset2, sizeof nset2); | 737 | |
700 | reg_w_buf(gspca_dev, nset3, sizeof nset3); | 738 | reg_w_buf(gspca_dev, sensor_data[sd->sensor].data1, |
701 | reg_w_buf(gspca_dev, nset4, sizeof nset4); | 739 | sizeof sensor_data[sd->sensor].data1); |
740 | reg_w_buf(gspca_dev, sensor_data[sd->sensor].data3, | ||
741 | sizeof sensor_data[sd->sensor].data3); | ||
742 | reg_w_buf(gspca_dev, sensor_data[sd->sensor].data2, | ||
743 | sizeof sensor_data[sd->sensor].data2); | ||
702 | 744 | ||
703 | return 0; | 745 | return 0; |
704 | } | 746 | } |
@@ -744,16 +786,43 @@ static void setlightfreq(struct gspca_dev *gspca_dev) | |||
744 | reg_w_buf(gspca_dev, freq, sizeof freq); | 786 | reg_w_buf(gspca_dev, freq, sizeof freq); |
745 | } | 787 | } |
746 | 788 | ||
789 | /* Is this really needed? | ||
790 | * i added some module parameters for test with some users */ | ||
791 | static void poll_sensor(struct gspca_dev *gspca_dev) | ||
792 | { | ||
793 | struct sd *sd = (struct sd *) gspca_dev; | ||
794 | static const __u8 poll1[] = | ||
795 | {0x67, 0x05, 0x68, 0x81, 0x69, 0x80, 0x6a, 0x82, | ||
796 | 0x6b, 0x68, 0x6c, 0x69, 0x72, 0xd9, 0x73, 0x34, | ||
797 | 0x74, 0x32, 0x75, 0x92, 0x76, 0x00, 0x09, 0x01, | ||
798 | 0x60, 0x14}; | ||
799 | static const __u8 poll2[] = | ||
800 | {0x67, 0x02, 0x68, 0x71, 0x69, 0x72, 0x72, 0xa9, | ||
801 | 0x73, 0x02, 0x73, 0x02, 0x60, 0x14}; | ||
802 | static const __u8 poll3[] = | ||
803 | {0x87, 0x3f, 0x88, 0x20, 0x89, 0x2d}; | ||
804 | static const __u8 poll4[] = | ||
805 | {0xa6, 0x0a, 0xea, 0xcf, 0xbe, 0x26, 0xb1, 0x5f, | ||
806 | 0xa1, 0xb1, 0xda, 0x6b, 0xdb, 0x98, 0xdf, 0x0c, | ||
807 | 0xc2, 0x80, 0xc3, 0x10}; | ||
808 | |||
809 | if (sd->sensor != SENSOR_TAS5130A) { | ||
810 | PDEBUG(D_STREAM, "[Sensor requires polling]"); | ||
811 | reg_w_buf(gspca_dev, poll1, sizeof poll1); | ||
812 | reg_w_buf(gspca_dev, poll2, sizeof poll2); | ||
813 | reg_w_buf(gspca_dev, poll3, sizeof poll3); | ||
814 | reg_w_buf(gspca_dev, poll4, sizeof poll4); | ||
815 | } | ||
816 | } | ||
817 | |||
747 | static int sd_start(struct gspca_dev *gspca_dev) | 818 | static int sd_start(struct gspca_dev *gspca_dev) |
748 | { | 819 | { |
749 | struct sd *sd = (struct sd *) gspca_dev; | 820 | struct sd *sd = (struct sd *) gspca_dev; |
750 | int i, mode; | 821 | int i, mode; |
751 | static const __u8 t1[] = { 0x66, 0x00, 0xa8, 0xe8 }; | ||
752 | __u8 t2[] = { 0x07, 0x00, 0x0d, 0x60, 0x0e, 0x80 }; | 822 | __u8 t2[] = { 0x07, 0x00, 0x0d, 0x60, 0x0e, 0x80 }; |
753 | static const __u8 t3[] = | 823 | static const __u8 t3[] = |
754 | { 0xb3, 0x07, 0xb4, 0x00, 0xb5, 0x88, 0xb6, 0x02, 0xb7, 0x06, | 824 | { 0xb3, 0x07, 0xb4, 0x00, 0xb5, 0x88, 0xb6, 0x02, 0xb7, 0x06, |
755 | 0xb8, 0x00, 0xb9, 0xe7, 0xba, 0x01 }; | 825 | 0xb8, 0x00, 0xb9, 0xe7, 0xba, 0x01 }; |
756 | static const __u8 t4[] = { 0x0b, 0x04, 0x0a, 0x40 }; | ||
757 | 826 | ||
758 | mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode]. priv; | 827 | mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode]. priv; |
759 | switch (mode) { | 828 | switch (mode) { |
@@ -788,13 +857,17 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
788 | } else { | 857 | } else { |
789 | om6802_sensor_init(gspca_dev); | 858 | om6802_sensor_init(gspca_dev); |
790 | } | 859 | } |
791 | /* just in case and to keep sync with logs (for mine) */ | 860 | reg_w_buf(gspca_dev, sensor_data[sd->sensor].data4, |
792 | reg_w_buf(gspca_dev, t1, sizeof t1); | 861 | sizeof sensor_data[sd->sensor].data4); |
793 | reg_w_buf(gspca_dev, t2, sizeof t2); | ||
794 | reg_r(gspca_dev, 0x0012); | 862 | reg_r(gspca_dev, 0x0012); |
863 | reg_w_buf(gspca_dev, t2, sizeof t2); | ||
795 | reg_w_buf(gspca_dev, t3, sizeof t3); | 864 | reg_w_buf(gspca_dev, t3, sizeof t3); |
796 | reg_w(gspca_dev, 0x0013); | 865 | reg_w(gspca_dev, 0x0013); |
797 | reg_w_buf(gspca_dev, t4, sizeof t4); | 866 | msleep(15); |
867 | reg_w_buf(gspca_dev, sensor_data[sd->sensor].stream, | ||
868 | sizeof sensor_data[sd->sensor].stream); | ||
869 | poll_sensor(gspca_dev); | ||
870 | |||
798 | /* restart on each start, just in case, sometimes regs goes wrong | 871 | /* restart on each start, just in case, sometimes regs goes wrong |
799 | * when using controls from app */ | 872 | * when using controls from app */ |
800 | setbrightness(gspca_dev); | 873 | setbrightness(gspca_dev); |