aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2010-10-27 05:38:07 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-12-29 05:16:31 -0500
commite0657be5615f666f261206ed62c3f0dc2527956e (patch)
tree7b9401301f75c042e967274cab58bd95115308c0 /drivers
parent2c4e776aa370a7a1619c7ada0604e9003fe1d92a (diff)
[media] gspca_xirlink_cit: Add support camera button
gspca_xirlink_cit: Add support camera button Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/video/gspca/xirlink_cit.c117
1 files changed, 84 insertions, 33 deletions
diff --git a/drivers/media/video/gspca/xirlink_cit.c b/drivers/media/video/gspca/xirlink_cit.c
index 157fbedbf493..5b5039a02031 100644
--- a/drivers/media/video/gspca/xirlink_cit.c
+++ b/drivers/media/video/gspca/xirlink_cit.c
@@ -29,6 +29,7 @@
29 29
30#define MODULE_NAME "xirlink-cit" 30#define MODULE_NAME "xirlink-cit"
31 31
32#include <linux/input.h>
32#include "gspca.h" 33#include "gspca.h"
33 34
34MODULE_AUTHOR("Hans de Goede <hdegoede@redhat.com>"); 35MODULE_AUTHOR("Hans de Goede <hdegoede@redhat.com>");
@@ -58,6 +59,7 @@ struct sd {
58#define CIT_MODEL4 4 59#define CIT_MODEL4 4
59#define CIT_IBM_NETCAM_PRO 5 60#define CIT_IBM_NETCAM_PRO 5
60 u8 input_index; 61 u8 input_index;
62 u8 button_state;
61 u8 stop_on_control_change; 63 u8 stop_on_control_change;
62 u8 sof_read; 64 u8 sof_read;
63 u8 sof_len; 65 u8 sof_len;
@@ -804,7 +806,7 @@ static int cit_write_reg(struct gspca_dev *gspca_dev, u16 value, u16 index)
804 return 0; 806 return 0;
805} 807}
806 808
807static int cit_read_reg(struct gspca_dev *gspca_dev, u16 index) 809static int cit_read_reg(struct gspca_dev *gspca_dev, u16 index, int verbose)
808{ 810{
809 struct usb_device *udev = gspca_dev->dev; 811 struct usb_device *udev = gspca_dev->dev;
810 __u8 *buf = gspca_dev->usb_buf; 812 __u8 *buf = gspca_dev->usb_buf;
@@ -819,10 +821,8 @@ static int cit_read_reg(struct gspca_dev *gspca_dev, u16 index)
819 return res; 821 return res;
820 } 822 }
821 823
822 PDEBUG(D_PROBE, 824 if (verbose)
823 "Register %04x value: %02x %02x %02x %02x %02x %02x %02x %02x", 825 PDEBUG(D_PROBE, "Register %04x value: %02x", index, buf[0]);
824 index,
825 buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7]);
826 826
827 return 0; 827 return 0;
828} 828}
@@ -907,7 +907,7 @@ static void cit_Packet_Format1(struct gspca_dev *gspca_dev, u16 fkey, u16 val)
907 cit_send_x_00_05(gspca_dev, 0x0089); 907 cit_send_x_00_05(gspca_dev, 0x0089);
908 cit_send_x_00(gspca_dev, fkey); 908 cit_send_x_00(gspca_dev, fkey);
909 cit_send_00_04_06(gspca_dev); 909 cit_send_00_04_06(gspca_dev);
910 cit_read_reg(gspca_dev, 0x0126); 910 cit_read_reg(gspca_dev, 0x0126, 0);
911 cit_send_FF_04_02(gspca_dev); 911 cit_send_FF_04_02(gspca_dev);
912} 912}
913 913
@@ -1074,12 +1074,12 @@ static int cit_init_model0(struct gspca_dev *gspca_dev)
1074 1074
1075static int cit_init_ibm_netcam_pro(struct gspca_dev *gspca_dev) 1075static int cit_init_ibm_netcam_pro(struct gspca_dev *gspca_dev)
1076{ 1076{
1077 cit_read_reg(gspca_dev, 0x128); 1077 cit_read_reg(gspca_dev, 0x128, 1);
1078 cit_write_reg(gspca_dev, 0x0003, 0x0133); 1078 cit_write_reg(gspca_dev, 0x0003, 0x0133);
1079 cit_write_reg(gspca_dev, 0x0000, 0x0117); 1079 cit_write_reg(gspca_dev, 0x0000, 0x0117);
1080 cit_write_reg(gspca_dev, 0x0008, 0x0123); 1080 cit_write_reg(gspca_dev, 0x0008, 0x0123);
1081 cit_write_reg(gspca_dev, 0x0000, 0x0100); 1081 cit_write_reg(gspca_dev, 0x0000, 0x0100);
1082 cit_read_reg(gspca_dev, 0x0116); 1082 cit_read_reg(gspca_dev, 0x0116, 0);
1083 cit_write_reg(gspca_dev, 0x0060, 0x0116); 1083 cit_write_reg(gspca_dev, 0x0060, 0x0116);
1084 cit_write_reg(gspca_dev, 0x0002, 0x0112); 1084 cit_write_reg(gspca_dev, 0x0002, 0x0112);
1085 cit_write_reg(gspca_dev, 0x0000, 0x0133); 1085 cit_write_reg(gspca_dev, 0x0000, 0x0133);
@@ -1098,7 +1098,7 @@ static int cit_init_ibm_netcam_pro(struct gspca_dev *gspca_dev)
1098 cit_write_reg(gspca_dev, 0x00ff, 0x0130); 1098 cit_write_reg(gspca_dev, 0x00ff, 0x0130);
1099 cit_write_reg(gspca_dev, 0xcd41, 0x0124); 1099 cit_write_reg(gspca_dev, 0xcd41, 0x0124);
1100 cit_write_reg(gspca_dev, 0xfffa, 0x0124); 1100 cit_write_reg(gspca_dev, 0xfffa, 0x0124);
1101 cit_read_reg(gspca_dev, 0x0126); 1101 cit_read_reg(gspca_dev, 0x0126, 1);
1102 1102
1103 cit_model3_Packet1(gspca_dev, 0x0000, 0x0000); 1103 cit_model3_Packet1(gspca_dev, 0x0000, 0x0000);
1104 cit_model3_Packet1(gspca_dev, 0x0000, 0x0001); 1104 cit_model3_Packet1(gspca_dev, 0x0000, 0x0001);
@@ -1557,18 +1557,20 @@ static int cit_restart_stream(struct gspca_dev *gspca_dev)
1557 switch (sd->model) { 1557 switch (sd->model) {
1558 case CIT_MODEL0: 1558 case CIT_MODEL0:
1559 case CIT_MODEL1: 1559 case CIT_MODEL1:
1560 case CIT_MODEL3:
1561 case CIT_IBM_NETCAM_PRO:
1562 cit_write_reg(gspca_dev, 0x0001, 0x0114); 1560 cit_write_reg(gspca_dev, 0x0001, 0x0114);
1563 /* Fall through */ 1561 /* Fall through */
1564 case CIT_MODEL2: 1562 case CIT_MODEL2:
1565 case CIT_MODEL4: 1563 case CIT_MODEL4:
1566 cit_write_reg(gspca_dev, 0x00c0, 0x010c); /* Go! */ 1564 cit_write_reg(gspca_dev, 0x00c0, 0x010c); /* Go! */
1567 usb_clear_halt(gspca_dev->dev, gspca_dev->urb[0]->pipe); 1565 usb_clear_halt(gspca_dev->dev, gspca_dev->urb[0]->pipe);
1568 /* This happens repeatedly while streaming with the ibm netcam 1566 break;
1569 pro and the ibmcam driver did it for model3 after changing 1567 case CIT_MODEL3:
1570 settings, but it does not seem to have any effect. */ 1568 case CIT_IBM_NETCAM_PRO:
1571 /* cit_write_reg(gspca_dev, 0x0001, 0x0113); */ 1569 cit_write_reg(gspca_dev, 0x0001, 0x0114);
1570 cit_write_reg(gspca_dev, 0x00c0, 0x010c); /* Go! */
1571 usb_clear_halt(gspca_dev->dev, gspca_dev->urb[0]->pipe);
1572 /* Clear button events from while we were not streaming */
1573 cit_write_reg(gspca_dev, 0x0001, 0x0113);
1572 break; 1574 break;
1573 } 1575 }
1574 1576
@@ -1680,23 +1682,23 @@ static int cit_start_model1(struct gspca_dev *gspca_dev)
1680 if (clock_div < 0) 1682 if (clock_div < 0)
1681 return clock_div; 1683 return clock_div;
1682 1684
1683 cit_read_reg(gspca_dev, 0x0128); 1685 cit_read_reg(gspca_dev, 0x0128, 1);
1684 cit_read_reg(gspca_dev, 0x0100); 1686 cit_read_reg(gspca_dev, 0x0100, 0);
1685 cit_write_reg(gspca_dev, 0x01, 0x0100); /* LED On */ 1687 cit_write_reg(gspca_dev, 0x01, 0x0100); /* LED On */
1686 cit_read_reg(gspca_dev, 0x0100); 1688 cit_read_reg(gspca_dev, 0x0100, 0);
1687 cit_write_reg(gspca_dev, 0x81, 0x0100); /* LED Off */ 1689 cit_write_reg(gspca_dev, 0x81, 0x0100); /* LED Off */
1688 cit_read_reg(gspca_dev, 0x0100); 1690 cit_read_reg(gspca_dev, 0x0100, 0);
1689 cit_write_reg(gspca_dev, 0x01, 0x0100); /* LED On */ 1691 cit_write_reg(gspca_dev, 0x01, 0x0100); /* LED On */
1690 cit_write_reg(gspca_dev, 0x01, 0x0108); 1692 cit_write_reg(gspca_dev, 0x01, 0x0108);
1691 1693
1692 cit_write_reg(gspca_dev, 0x03, 0x0112); 1694 cit_write_reg(gspca_dev, 0x03, 0x0112);
1693 cit_read_reg(gspca_dev, 0x0115); 1695 cit_read_reg(gspca_dev, 0x0115, 0);
1694 cit_write_reg(gspca_dev, 0x06, 0x0115); 1696 cit_write_reg(gspca_dev, 0x06, 0x0115);
1695 cit_read_reg(gspca_dev, 0x0116); 1697 cit_read_reg(gspca_dev, 0x0116, 0);
1696 cit_write_reg(gspca_dev, 0x44, 0x0116); 1698 cit_write_reg(gspca_dev, 0x44, 0x0116);
1697 cit_read_reg(gspca_dev, 0x0116); 1699 cit_read_reg(gspca_dev, 0x0116, 0);
1698 cit_write_reg(gspca_dev, 0x40, 0x0116); 1700 cit_write_reg(gspca_dev, 0x40, 0x0116);
1699 cit_read_reg(gspca_dev, 0x0115); 1701 cit_read_reg(gspca_dev, 0x0115, 0);
1700 cit_write_reg(gspca_dev, 0x0e, 0x0115); 1702 cit_write_reg(gspca_dev, 0x0e, 0x0115);
1701 cit_write_reg(gspca_dev, 0x19, 0x012c); 1703 cit_write_reg(gspca_dev, 0x19, 0x012c);
1702 1704
@@ -1878,7 +1880,7 @@ static int cit_start_model2(struct gspca_dev *gspca_dev)
1878 int clock_div = 0; 1880 int clock_div = 0;
1879 1881
1880 cit_write_reg(gspca_dev, 0x0000, 0x0100); /* LED on */ 1882 cit_write_reg(gspca_dev, 0x0000, 0x0100); /* LED on */
1881 cit_read_reg(gspca_dev, 0x0116); 1883 cit_read_reg(gspca_dev, 0x0116, 0);
1882 cit_write_reg(gspca_dev, 0x0060, 0x0116); 1884 cit_write_reg(gspca_dev, 0x0060, 0x0116);
1883 cit_write_reg(gspca_dev, 0x0002, 0x0112); 1885 cit_write_reg(gspca_dev, 0x0002, 0x0112);
1884 cit_write_reg(gspca_dev, 0x00bc, 0x012c); 1886 cit_write_reg(gspca_dev, 0x00bc, 0x012c);
@@ -2070,10 +2072,10 @@ static int cit_start_model3(struct gspca_dev *gspca_dev)
2070 2072
2071 /* HDG not in ibmcam driver, added to see if it helps with 2073 /* HDG not in ibmcam driver, added to see if it helps with
2072 auto-detecting between model3 and ibm netcamera pro */ 2074 auto-detecting between model3 and ibm netcamera pro */
2073 cit_read_reg(gspca_dev, 0x128); 2075 cit_read_reg(gspca_dev, 0x128, 1);
2074 2076
2075 cit_write_reg(gspca_dev, 0x0000, 0x0100); 2077 cit_write_reg(gspca_dev, 0x0000, 0x0100);
2076 cit_read_reg(gspca_dev, 0x0116); 2078 cit_read_reg(gspca_dev, 0x0116, 0);
2077 cit_write_reg(gspca_dev, 0x0060, 0x0116); 2079 cit_write_reg(gspca_dev, 0x0060, 0x0116);
2078 cit_write_reg(gspca_dev, 0x0002, 0x0112); 2080 cit_write_reg(gspca_dev, 0x0002, 0x0112);
2079 cit_write_reg(gspca_dev, 0x0000, 0x0123); 2081 cit_write_reg(gspca_dev, 0x0000, 0x0123);
@@ -2083,7 +2085,7 @@ static int cit_start_model3(struct gspca_dev *gspca_dev)
2083 cit_write_reg(gspca_dev, 0x0060, 0x0116); 2085 cit_write_reg(gspca_dev, 0x0060, 0x0116);
2084 cit_write_reg(gspca_dev, 0x0002, 0x0115); 2086 cit_write_reg(gspca_dev, 0x0002, 0x0115);
2085 cit_write_reg(gspca_dev, 0x0003, 0x0115); 2087 cit_write_reg(gspca_dev, 0x0003, 0x0115);
2086 cit_read_reg(gspca_dev, 0x0115); 2088 cit_read_reg(gspca_dev, 0x0115, 0);
2087 cit_write_reg(gspca_dev, 0x000b, 0x0115); 2089 cit_write_reg(gspca_dev, 0x000b, 0x0115);
2088 2090
2089 /* TESTME HDG not in ibmcam driver, added to see if it helps with 2091 /* TESTME HDG not in ibmcam driver, added to see if it helps with
@@ -2096,7 +2098,7 @@ static int cit_start_model3(struct gspca_dev *gspca_dev)
2096 cit_write_reg(gspca_dev, 0x00ff, 0x0130); 2098 cit_write_reg(gspca_dev, 0x00ff, 0x0130);
2097 cit_write_reg(gspca_dev, 0xcd41, 0x0124); 2099 cit_write_reg(gspca_dev, 0xcd41, 0x0124);
2098 cit_write_reg(gspca_dev, 0xfffa, 0x0124); 2100 cit_write_reg(gspca_dev, 0xfffa, 0x0124);
2099 cit_read_reg(gspca_dev, 0x0126); 2101 cit_read_reg(gspca_dev, 0x0126, 1);
2100 } 2102 }
2101 2103
2102 cit_model3_Packet1(gspca_dev, 0x000a, 0x0040); 2104 cit_model3_Packet1(gspca_dev, 0x000a, 0x0040);
@@ -2293,7 +2295,7 @@ static int cit_start_model3(struct gspca_dev *gspca_dev)
2293 if (rca_input) { 2295 if (rca_input) {
2294 for (i = 0; i < ARRAY_SIZE(rca_initdata); i++) { 2296 for (i = 0; i < ARRAY_SIZE(rca_initdata); i++) {
2295 if (rca_initdata[i][0]) 2297 if (rca_initdata[i][0])
2296 cit_read_reg(gspca_dev, rca_initdata[i][2]); 2298 cit_read_reg(gspca_dev, rca_initdata[i][2], 0);
2297 else 2299 else
2298 cit_write_reg(gspca_dev, rca_initdata[i][1], 2300 cit_write_reg(gspca_dev, rca_initdata[i][1],
2299 rca_initdata[i][2]); 2301 rca_initdata[i][2]);
@@ -2712,7 +2714,7 @@ static int cit_start_ibm_netcam_pro(struct gspca_dev *gspca_dev)
2712 if (rca_input) { 2714 if (rca_input) {
2713 for (i = 0; i < ARRAY_SIZE(rca_initdata); i++) { 2715 for (i = 0; i < ARRAY_SIZE(rca_initdata); i++) {
2714 if (rca_initdata[i][0]) 2716 if (rca_initdata[i][0])
2715 cit_read_reg(gspca_dev, rca_initdata[i][2]); 2717 cit_read_reg(gspca_dev, rca_initdata[i][2], 0);
2716 else 2718 else
2717 cit_write_reg(gspca_dev, rca_initdata[i][1], 2719 cit_write_reg(gspca_dev, rca_initdata[i][1],
2718 rca_initdata[i][2]); 2720 rca_initdata[i][2]);
@@ -2851,7 +2853,7 @@ static void sd_stop0(struct gspca_dev *gspca_dev)
2851 break; 2853 break;
2852 case CIT_MODEL1: 2854 case CIT_MODEL1:
2853 cit_send_FF_04_02(gspca_dev); 2855 cit_send_FF_04_02(gspca_dev);
2854 cit_read_reg(gspca_dev, 0x0100); 2856 cit_read_reg(gspca_dev, 0x0100, 0);
2855 cit_write_reg(gspca_dev, 0x81, 0x0100); /* LED Off */ 2857 cit_write_reg(gspca_dev, 0x81, 0x0100); /* LED Off */
2856 break; 2858 break;
2857 case CIT_MODEL2: 2859 case CIT_MODEL2:
@@ -2870,9 +2872,9 @@ static void sd_stop0(struct gspca_dev *gspca_dev)
2870 case CIT_MODEL3: 2872 case CIT_MODEL3:
2871 cit_write_reg(gspca_dev, 0x0006, 0x012c); 2873 cit_write_reg(gspca_dev, 0x0006, 0x012c);
2872 cit_model3_Packet1(gspca_dev, 0x0046, 0x0000); 2874 cit_model3_Packet1(gspca_dev, 0x0046, 0x0000);
2873 cit_read_reg(gspca_dev, 0x0116); 2875 cit_read_reg(gspca_dev, 0x0116, 0);
2874 cit_write_reg(gspca_dev, 0x0064, 0x0116); 2876 cit_write_reg(gspca_dev, 0x0064, 0x0116);
2875 cit_read_reg(gspca_dev, 0x0115); 2877 cit_read_reg(gspca_dev, 0x0115, 0);
2876 cit_write_reg(gspca_dev, 0x0003, 0x0115); 2878 cit_write_reg(gspca_dev, 0x0003, 0x0115);
2877 cit_write_reg(gspca_dev, 0x0008, 0x0123); 2879 cit_write_reg(gspca_dev, 0x0008, 0x0123);
2878 cit_write_reg(gspca_dev, 0x0000, 0x0117); 2880 cit_write_reg(gspca_dev, 0x0000, 0x0117);
@@ -2897,6 +2899,15 @@ static void sd_stop0(struct gspca_dev *gspca_dev)
2897 cit_write_reg(gspca_dev, 0x00c0, 0x0100); 2899 cit_write_reg(gspca_dev, 0x00c0, 0x0100);
2898 break; 2900 break;
2899 } 2901 }
2902
2903#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
2904 /* If the last button state is pressed, release it now! */
2905 if (sd->button_state) {
2906 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0);
2907 input_sync(gspca_dev->input_dev);
2908 sd->button_state = 0;
2909 }
2910#endif
2900} 2911}
2901 2912
2902static u8 *cit_find_sof(struct gspca_dev *gspca_dev, u8 *data, int len) 2913static u8 *cit_find_sof(struct gspca_dev *gspca_dev, u8 *data, int len)
@@ -3190,6 +3201,38 @@ static int sd_gethflip(struct gspca_dev *gspca_dev, __s32 *val)
3190 return 0; 3201 return 0;
3191} 3202}
3192 3203
3204#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
3205static void cit_check_button(struct gspca_dev *gspca_dev)
3206{
3207 int new_button_state;
3208 struct sd *sd = (struct sd *)gspca_dev;
3209
3210 switch (sd->model) {
3211 case CIT_MODEL3:
3212 case CIT_IBM_NETCAM_PRO:
3213 break;
3214 default: /* TEST ME unknown if this works on other models too */
3215 return;
3216 }
3217
3218 /* Read the button state */
3219 cit_read_reg(gspca_dev, 0x0113, 0);
3220 new_button_state = !gspca_dev->usb_buf[0];
3221
3222 /* Tell the cam we've seen the button press, notice that this
3223 is a nop (iow the cam keeps reporting pressed) until the
3224 button is actually released. */
3225 if (new_button_state)
3226 cit_write_reg(gspca_dev, 0x01, 0x0113);
3227
3228 if (sd->button_state != new_button_state) {
3229 input_report_key(gspca_dev->input_dev, KEY_CAMERA,
3230 new_button_state);
3231 input_sync(gspca_dev->input_dev);
3232 sd->button_state = new_button_state;
3233 }
3234}
3235#endif
3193 3236
3194/* sub-driver description */ 3237/* sub-driver description */
3195static const struct sd_desc sd_desc = { 3238static const struct sd_desc sd_desc = {
@@ -3202,6 +3245,10 @@ static const struct sd_desc sd_desc = {
3202 .stopN = sd_stopN, 3245 .stopN = sd_stopN,
3203 .stop0 = sd_stop0, 3246 .stop0 = sd_stop0,
3204 .pkt_scan = sd_pkt_scan, 3247 .pkt_scan = sd_pkt_scan,
3248#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
3249 .dq_callback = cit_check_button,
3250 .other_input = 1,
3251#endif
3205}; 3252};
3206 3253
3207static const struct sd_desc sd_desc_isoc_nego = { 3254static const struct sd_desc sd_desc_isoc_nego = {
@@ -3216,6 +3263,10 @@ static const struct sd_desc sd_desc_isoc_nego = {
3216 .stopN = sd_stopN, 3263 .stopN = sd_stopN,
3217 .stop0 = sd_stop0, 3264 .stop0 = sd_stop0,
3218 .pkt_scan = sd_pkt_scan, 3265 .pkt_scan = sd_pkt_scan,
3266#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
3267 .dq_callback = cit_check_button,
3268 .other_input = 1,
3269#endif
3219}; 3270};
3220 3271
3221/* -- module initialisation -- */ 3272/* -- module initialisation -- */