diff options
author | Devin Heitmueller <devin.heitmueller@gmail.com> | 2008-06-28 07:57:06 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-07-20 06:12:48 -0400 |
commit | a9fc52bcbeb5245b58d23c558f3e3e8f18bebbc3 (patch) | |
tree | bd0f1f54ed1ee0f3994a38ecebe6dc5fb00c4bc5 /drivers/media/video/em28xx/em28xx-input.c | |
parent | 305519c924d8f2f2f85c390c6d456dc41dbe0284 (diff) |
V4L/DVB (8123): Add support for em2860 based PointNix Intra-Oral Camera
em28xx-cards.c
em28xx-input.c
em28xx-video.c
em28xx.h
- Add support for the PointNix Intra-Oral Camera, which required addition of
a construct for reading the "snapshot" button (provided on the em2860 and
em2880 chips, but this is the first case where I have seen it actually used
in a product). The button is wired to pin 56 on the em2880.
http://www.pointnix.com/ENG/dental/product_02.asp
Thanks to Roberto Mantovani <rmantovani@libero.it> for testing the changes
Signed-off-by: Devin Heitmueller <devin.heitmueller@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/em28xx/em28xx-input.c')
-rw-r--r-- | drivers/media/video/em28xx/em28xx-input.c | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/drivers/media/video/em28xx/em28xx-input.c b/drivers/media/video/em28xx/em28xx-input.c index bb5807159b8d..eab3d9511af3 100644 --- a/drivers/media/video/em28xx/em28xx-input.c +++ b/drivers/media/video/em28xx/em28xx-input.c | |||
@@ -30,6 +30,10 @@ | |||
30 | 30 | ||
31 | #include "em28xx.h" | 31 | #include "em28xx.h" |
32 | 32 | ||
33 | #define EM28XX_SNAPSHOT_KEY KEY_CAMERA | ||
34 | #define EM28XX_SBUTTON_QUERY_INTERVAL 500 | ||
35 | #define EM28XX_R0C_USBSUSP_SNAPSHOT 0x20 | ||
36 | |||
33 | static unsigned int ir_debug; | 37 | static unsigned int ir_debug; |
34 | module_param(ir_debug, int, 0644); | 38 | module_param(ir_debug, int, 0644); |
35 | MODULE_PARM_DESC(ir_debug, "enable debug messages [IR]"); | 39 | MODULE_PARM_DESC(ir_debug, "enable debug messages [IR]"); |
@@ -124,6 +128,89 @@ int em28xx_get_key_pinnacle_usb_grey(struct IR_i2c *ir, u32 *ir_key, | |||
124 | return 1; | 128 | return 1; |
125 | } | 129 | } |
126 | 130 | ||
131 | static void em28xx_query_sbutton(struct work_struct *work) | ||
132 | { | ||
133 | /* Poll the register and see if the button is depressed */ | ||
134 | struct em28xx *dev = | ||
135 | container_of(work, struct em28xx, sbutton_query_work.work); | ||
136 | int ret; | ||
137 | |||
138 | ret = em28xx_read_reg(dev, EM28XX_R0C_USBSUSP); | ||
139 | |||
140 | if (ret & EM28XX_R0C_USBSUSP_SNAPSHOT) { | ||
141 | u8 cleared; | ||
142 | /* Button is depressed, clear the register */ | ||
143 | cleared = ((u8) ret) & ~EM28XX_R0C_USBSUSP_SNAPSHOT; | ||
144 | em28xx_write_regs(dev, EM28XX_R0C_USBSUSP, &cleared, 1); | ||
145 | |||
146 | /* Not emulate the keypress */ | ||
147 | input_report_key(dev->sbutton_input_dev, EM28XX_SNAPSHOT_KEY, | ||
148 | 1); | ||
149 | /* Now unpress the key */ | ||
150 | input_report_key(dev->sbutton_input_dev, EM28XX_SNAPSHOT_KEY, | ||
151 | 0); | ||
152 | } | ||
153 | |||
154 | /* Schedule next poll */ | ||
155 | schedule_delayed_work(&dev->sbutton_query_work, | ||
156 | msecs_to_jiffies(EM28XX_SBUTTON_QUERY_INTERVAL)); | ||
157 | } | ||
158 | |||
159 | void em28xx_register_snapshot_button(struct em28xx *dev) | ||
160 | { | ||
161 | struct input_dev *input_dev; | ||
162 | int err; | ||
163 | |||
164 | em28xx_info("Registering snapshot button...\n"); | ||
165 | input_dev = input_allocate_device(); | ||
166 | if (!input_dev) { | ||
167 | em28xx_errdev("input_allocate_device failed\n"); | ||
168 | return; | ||
169 | } | ||
170 | |||
171 | usb_make_path(dev->udev, dev->snapshot_button_path, | ||
172 | sizeof(dev->snapshot_button_path)); | ||
173 | strlcat(dev->snapshot_button_path, "/sbutton", | ||
174 | sizeof(dev->snapshot_button_path)); | ||
175 | INIT_DELAYED_WORK(&dev->sbutton_query_work, em28xx_query_sbutton); | ||
176 | |||
177 | input_dev->name = "em28xx snapshot button"; | ||
178 | input_dev->phys = dev->snapshot_button_path; | ||
179 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP); | ||
180 | set_bit(EM28XX_SNAPSHOT_KEY, input_dev->keybit); | ||
181 | input_dev->keycodesize = 0; | ||
182 | input_dev->keycodemax = 0; | ||
183 | input_dev->id.bustype = BUS_USB; | ||
184 | input_dev->id.vendor = le16_to_cpu(dev->udev->descriptor.idVendor); | ||
185 | input_dev->id.product = le16_to_cpu(dev->udev->descriptor.idProduct); | ||
186 | input_dev->id.version = 1; | ||
187 | input_dev->dev.parent = &dev->udev->dev; | ||
188 | |||
189 | err = input_register_device(input_dev); | ||
190 | if (err) { | ||
191 | em28xx_errdev("input_register_device failed\n"); | ||
192 | input_free_device(input_dev); | ||
193 | return; | ||
194 | } | ||
195 | |||
196 | dev->sbutton_input_dev = input_dev; | ||
197 | schedule_delayed_work(&dev->sbutton_query_work, | ||
198 | msecs_to_jiffies(EM28XX_SBUTTON_QUERY_INTERVAL)); | ||
199 | return; | ||
200 | |||
201 | } | ||
202 | |||
203 | void em28xx_deregister_snapshot_button(struct em28xx *dev) | ||
204 | { | ||
205 | if (dev->sbutton_input_dev != NULL) { | ||
206 | em28xx_info("Deregistering snapshot button\n"); | ||
207 | cancel_rearming_delayed_work(&dev->sbutton_query_work); | ||
208 | input_unregister_device(dev->sbutton_input_dev); | ||
209 | dev->sbutton_input_dev = NULL; | ||
210 | } | ||
211 | return; | ||
212 | } | ||
213 | |||
127 | /* ---------------------------------------------------------------------- | 214 | /* ---------------------------------------------------------------------- |
128 | * Local variables: | 215 | * Local variables: |
129 | * c-basic-offset: 8 | 216 | * c-basic-offset: 8 |