29 #include <linux/kernel.h>
31 #include <linux/module.h>
32 #include <linux/slab.h>
38 #if defined(CONFIG_LEDS_CLASS) || \
39 (defined(CONFIG_LEDS_CLASS_MODULE) && defined(CONFIG_RADIO_SHARK2_MODULE))
40 #define SHARK_USE_LEDS 1
51 #define SHARK_IN_EP 0x83
52 #define SHARK_OUT_EP 0x05
55 #define DRV_NAME "radioshark2"
57 #define v4l2_dev_to_shark(d) container_of(d, struct shark_device, v4l2_dev)
71 unsigned long brightness_new;
82 int i,
res, actual_len;
86 for (i = 0; i < 6; i++)
107 int i,
res, actual_len;
130 for (i = 0; i < 3; i++)
141 .write_reg = shark_write_reg,
142 .read_reg = shark_read_reg,
145 #ifdef SHARK_USE_LEDS
152 for (i = 0; i < 2; i++) {
161 usb_sndintpipe(shark->
usbdev,
167 shark->led_names[i], res);
171 static void shark_led_set_blue(
struct led_classdev *led_cdev,
182 static void shark_led_set_red(
struct led_classdev *led_cdev,
197 .max_brightness = 127,
198 .brightness_set = shark_led_set_blue,
204 .brightness_set = shark_led_set_red,
213 INIT_WORK(&shark->led_work, shark_led_work);
214 for (i = 0; i <
NO_LEDS; i++) {
215 shark->leds[
i] = shark_led_templates[
i];
216 snprintf(shark->led_names[i],
sizeof(shark->led_names[0]),
217 shark->leds[i].name, shark->
v4l2_dev.name);
218 shark->leds[
i].name = shark->led_names[
i];
222 "couldn't register led: %s\n",
223 shark->led_names[i]);
230 static void shark_unregister_leds(
struct shark_device *shark)
240 static void shark_resume_leds(
struct shark_device *shark)
245 set_bit(i, &shark->brightness_new);
253 "CONFIG_LED_CLASS not enabled, LED support disabled\n");
256 static inline void shark_unregister_leds(
struct shark_device *shark) { }
257 static inline void shark_resume_leds(
struct shark_device *shark) { }
262 struct v4l2_device *v4l2_dev = usb_get_intfdata(intf);
270 shark_unregister_leds(shark);
296 goto err_alloc_buffer;
300 retval = shark_register_leds(shark, &intf->dev);
304 shark->
v4l2_dev.release = usb_shark_release;
311 shark->
usbdev = interface_to_usbdev(intf);
313 shark->
tea.private_data = shark;
314 shark->
tea.ops = &shark_tea_ops;
315 shark->
tea.has_am =
true;
316 shark->
tea.write_before_read =
true;
317 strlcpy(shark->
tea.card,
"Griffin radioSHARK2",
318 sizeof(shark->
tea.card));
319 usb_make_path(shark->
usbdev, shark->
tea.bus_info,
320 sizeof(shark->
tea.bus_info));
333 shark_unregister_leds(shark);
350 struct v4l2_device *v4l2_dev = usb_get_intfdata(intf);
358 shark_resume_leds(shark);
366 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE_AND_VERSION |
370 .bcdDevice_lo = 0x0010,
371 .bcdDevice_hi = 0x0010,
372 .bInterfaceClass = 3,
378 static struct usb_driver usb_shark_driver = {
380 .probe = usb_shark_probe,
381 .disconnect = usb_shark_disconnect,
382 .id_table = usb_shark_device_table,
384 .suspend = usb_shark_suspend,
385 .resume = usb_shark_resume,
386 .reset_resume = usb_shark_resume,