diff options
author | Mike Isely <isely@pobox.com> | 2008-04-22 13:45:42 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-04-24 13:07:48 -0400 |
commit | 40381cb02fb7fc0b46c55e3a71325b5d930580fa (patch) | |
tree | a2654ff76b947f1aa3dcee9bc4ad77e7504d022b /drivers/media/video | |
parent | c55a97d7538d5f3abbee5486e37e56e896478fbd (diff) |
V4L/DVB (7313): pvrusb2: Make LED control into a device-specific attribute
The pvrusb2 driver has used hardcoded logic to control the LED on the
device. However this is really Hauppauge-specific behavior. This
change defines a new device attribute for LED control and sets things
up appropriately for Hauppauge devices.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video')
-rw-r--r-- | drivers/media/video/pvrusb2/pvrusb2-devattr.c | 3 | ||||
-rw-r--r-- | drivers/media/video/pvrusb2/pvrusb2-devattr.h | 8 | ||||
-rw-r--r-- | drivers/media/video/pvrusb2/pvrusb2-encoder.c | 4 | ||||
-rw-r--r-- | drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h | 3 | ||||
-rw-r--r-- | drivers/media/video/pvrusb2/pvrusb2-hdw.c | 39 | ||||
-rw-r--r-- | drivers/media/video/pvrusb2/pvrusb2-hdw.h | 3 |
6 files changed, 46 insertions, 14 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-devattr.c b/drivers/media/video/pvrusb2/pvrusb2-devattr.c index 1a60591e38b5..638c577e3268 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-devattr.c +++ b/drivers/media/video/pvrusb2/pvrusb2-devattr.c | |||
@@ -61,6 +61,7 @@ static const struct pvr2_device_desc pvr2_device_29xxx = { | |||
61 | .flag_has_composite = !0, | 61 | .flag_has_composite = !0, |
62 | .flag_has_svideo = !0, | 62 | .flag_has_svideo = !0, |
63 | .signal_routing_scheme = PVR2_ROUTING_SCHEME_HAUPPAUGE, | 63 | .signal_routing_scheme = PVR2_ROUTING_SCHEME_HAUPPAUGE, |
64 | .led_scheme = PVR2_LED_SCHEME_HAUPPAUGE, | ||
64 | }; | 65 | }; |
65 | 66 | ||
66 | 67 | ||
@@ -94,6 +95,7 @@ static const struct pvr2_device_desc pvr2_device_24xxx = { | |||
94 | .flag_has_composite = !0, | 95 | .flag_has_composite = !0, |
95 | .flag_has_svideo = !0, | 96 | .flag_has_svideo = !0, |
96 | .signal_routing_scheme = PVR2_ROUTING_SCHEME_HAUPPAUGE, | 97 | .signal_routing_scheme = PVR2_ROUTING_SCHEME_HAUPPAUGE, |
98 | .led_scheme = PVR2_LED_SCHEME_HAUPPAUGE, | ||
97 | }; | 99 | }; |
98 | 100 | ||
99 | 101 | ||
@@ -235,6 +237,7 @@ static const struct pvr2_device_desc pvr2_device_75xxx = { | |||
235 | .signal_routing_scheme = PVR2_ROUTING_SCHEME_HAUPPAUGE, | 237 | .signal_routing_scheme = PVR2_ROUTING_SCHEME_HAUPPAUGE, |
236 | .digital_control_scheme = PVR2_DIGITAL_SCHEME_HAUPPAUGE, | 238 | .digital_control_scheme = PVR2_DIGITAL_SCHEME_HAUPPAUGE, |
237 | .default_std_mask = V4L2_STD_NTSC_M, | 239 | .default_std_mask = V4L2_STD_NTSC_M, |
240 | .led_scheme = PVR2_LED_SCHEME_HAUPPAUGE, | ||
238 | }; | 241 | }; |
239 | 242 | ||
240 | 243 | ||
diff --git a/drivers/media/video/pvrusb2/pvrusb2-devattr.h b/drivers/media/video/pvrusb2/pvrusb2-devattr.h index 4e4798d6139f..ce4004978a92 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-devattr.h +++ b/drivers/media/video/pvrusb2/pvrusb2-devattr.h | |||
@@ -43,6 +43,9 @@ struct pvr2_string_table { | |||
43 | #define PVR2_DIGITAL_SCHEME_HAUPPAUGE 1 | 43 | #define PVR2_DIGITAL_SCHEME_HAUPPAUGE 1 |
44 | #define PVR2_DIGITAL_SCHEME_ONAIR 2 | 44 | #define PVR2_DIGITAL_SCHEME_ONAIR 2 |
45 | 45 | ||
46 | #define PVR2_LED_SCHEME_NONE 0 | ||
47 | #define PVR2_LED_SCHEME_HAUPPAUGE 1 | ||
48 | |||
46 | /* This describes a particular hardware type (except for the USB device ID | 49 | /* This describes a particular hardware type (except for the USB device ID |
47 | which must live in a separate structure due to environmental | 50 | which must live in a separate structure due to environmental |
48 | constraints). See the top of pvrusb2-hdw.c for where this is | 51 | constraints). See the top of pvrusb2-hdw.c for where this is |
@@ -70,6 +73,11 @@ struct pvr2_device_desc { | |||
70 | drivers (search for things which touch this field). */ | 73 | drivers (search for things which touch this field). */ |
71 | unsigned int signal_routing_scheme; | 74 | unsigned int signal_routing_scheme; |
72 | 75 | ||
76 | /* Indicates scheme for controlling device's LED (if any). The | ||
77 | driver will turn on the LED when streaming is underway. This | ||
78 | contains one of PVR2_LED_SCHEME_XXX. */ | ||
79 | unsigned int led_scheme; | ||
80 | |||
73 | /* Control scheme to use if there is a digital tuner. This | 81 | /* Control scheme to use if there is a digital tuner. This |
74 | contains one of PVR2_DIGITAL_SCHEME_XXX. This is an arbitrary | 82 | contains one of PVR2_DIGITAL_SCHEME_XXX. This is an arbitrary |
75 | integer scheme id; its meaning is contained entirely within the | 83 | integer scheme id; its meaning is contained entirely within the |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-encoder.c b/drivers/media/video/pvrusb2/pvrusb2-encoder.c index ccb5d14ddf85..324d1bd8500d 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-encoder.c +++ b/drivers/media/video/pvrusb2/pvrusb2-encoder.c | |||
@@ -480,8 +480,6 @@ int pvr2_encoder_start(struct pvr2_hdw *hdw) | |||
480 | /* unmask some interrupts */ | 480 | /* unmask some interrupts */ |
481 | pvr2_write_register(hdw, 0x0048, 0xbfffffff); | 481 | pvr2_write_register(hdw, 0x0048, 0xbfffffff); |
482 | 482 | ||
483 | pvr2_led_ctrl(hdw, 1); | ||
484 | |||
485 | pvr2_encoder_vcmd(hdw,CX2341X_ENC_MUTE_VIDEO,1, | 483 | pvr2_encoder_vcmd(hdw,CX2341X_ENC_MUTE_VIDEO,1, |
486 | hdw->input_val == PVR2_CVAL_INPUT_RADIO ? 1 : 0); | 484 | hdw->input_val == PVR2_CVAL_INPUT_RADIO ? 1 : 0); |
487 | 485 | ||
@@ -524,8 +522,6 @@ int pvr2_encoder_stop(struct pvr2_hdw *hdw) | |||
524 | break; | 522 | break; |
525 | } | 523 | } |
526 | 524 | ||
527 | pvr2_led_ctrl(hdw, 0); | ||
528 | |||
529 | return status; | 525 | return status; |
530 | } | 526 | } |
531 | 527 | ||
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h b/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h index af06e6c4b8d5..bc341ae5c79a 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h +++ b/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h | |||
@@ -253,6 +253,9 @@ struct pvr2_hdw { | |||
253 | PVR2_STATE_xxxx */ | 253 | PVR2_STATE_xxxx */ |
254 | unsigned int master_state; | 254 | unsigned int master_state; |
255 | 255 | ||
256 | /* True if device led is currently on */ | ||
257 | int led_on; | ||
258 | |||
256 | /* True if states must be re-evaluated */ | 259 | /* True if states must be re-evaluated */ |
257 | int state_stale; | 260 | int state_stale; |
258 | 261 | ||
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c index 9b1e22f2e555..c51c5cef82dd 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c +++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c | |||
@@ -3357,24 +3357,48 @@ static void pvr2_hdw_cmd_modeswitch(struct pvr2_hdw *hdw,int digitalFl) | |||
3357 | } | 3357 | } |
3358 | 3358 | ||
3359 | 3359 | ||
3360 | /* Toggle LED */ | 3360 | void pvr2_led_ctrl_hauppauge(struct pvr2_hdw *hdw, int onoff) |
3361 | int pvr2_led_ctrl(struct pvr2_hdw *hdw, int onoff) | ||
3362 | { | 3361 | { |
3363 | /* change some GPIO data | 3362 | /* change some GPIO data |
3364 | * | 3363 | * |
3365 | * note: bit d7 of dir appears to control the LED, | 3364 | * note: bit d7 of dir appears to control the LED, |
3366 | * so we shut it off here. | 3365 | * so we shut it off here. |
3367 | * | 3366 | * |
3368 | * FIXME: is this device-specific? | ||
3369 | */ | 3367 | */ |
3370 | if (onoff) | 3368 | if (onoff) { |
3371 | pvr2_hdw_gpio_chg_dir(hdw, 0xffffffff, 0x00000481); | 3369 | pvr2_hdw_gpio_chg_dir(hdw, 0xffffffff, 0x00000481); |
3372 | else | 3370 | } else { |
3373 | pvr2_hdw_gpio_chg_dir(hdw, 0xffffffff, 0x00000401); | 3371 | pvr2_hdw_gpio_chg_dir(hdw, 0xffffffff, 0x00000401); |
3374 | 3372 | } | |
3375 | pvr2_hdw_gpio_chg_out(hdw, 0xffffffff, 0x00000000); | 3373 | pvr2_hdw_gpio_chg_out(hdw, 0xffffffff, 0x00000000); |
3374 | } | ||
3376 | 3375 | ||
3377 | return 0; | 3376 | |
3377 | typedef void (*led_method_func)(struct pvr2_hdw *,int); | ||
3378 | |||
3379 | static led_method_func led_methods[] = { | ||
3380 | [PVR2_LED_SCHEME_HAUPPAUGE] = pvr2_led_ctrl_hauppauge, | ||
3381 | }; | ||
3382 | |||
3383 | |||
3384 | /* Toggle LED */ | ||
3385 | static void pvr2_led_ctrl(struct pvr2_hdw *hdw,int onoff) | ||
3386 | { | ||
3387 | unsigned int scheme_id; | ||
3388 | led_method_func fp; | ||
3389 | |||
3390 | if ((!onoff) == (!hdw->led_on)) return; | ||
3391 | |||
3392 | hdw->led_on = onoff != 0; | ||
3393 | |||
3394 | scheme_id = hdw->hdw_desc->led_scheme; | ||
3395 | if (scheme_id < ARRAY_SIZE(led_methods)) { | ||
3396 | fp = led_methods[scheme_id]; | ||
3397 | } else { | ||
3398 | fp = NULL; | ||
3399 | } | ||
3400 | |||
3401 | if (fp) (*fp)(hdw,onoff); | ||
3378 | } | 3402 | } |
3379 | 3403 | ||
3380 | 3404 | ||
@@ -3871,6 +3895,7 @@ static int pvr2_hdw_state_eval(struct pvr2_hdw *hdw) | |||
3871 | "Device state change from %s to %s", | 3895 | "Device state change from %s to %s", |
3872 | pvr2_get_state_name(hdw->master_state), | 3896 | pvr2_get_state_name(hdw->master_state), |
3873 | pvr2_get_state_name(st)); | 3897 | pvr2_get_state_name(st)); |
3898 | pvr2_led_ctrl(hdw,st == PVR2_STATE_RUN); | ||
3874 | hdw->master_state = st; | 3899 | hdw->master_state = st; |
3875 | state_updated = !0; | 3900 | state_updated = !0; |
3876 | callback_flag = !0; | 3901 | callback_flag = !0; |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.h b/drivers/media/video/pvrusb2/pvrusb2-hdw.h index 4fc9db3efff2..57e1ff491497 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-hdw.h +++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.h | |||
@@ -258,9 +258,6 @@ int pvr2_hdw_cmd_powerup(struct pvr2_hdw *); | |||
258 | /* suspend */ | 258 | /* suspend */ |
259 | int pvr2_hdw_cmd_powerdown(struct pvr2_hdw *); | 259 | int pvr2_hdw_cmd_powerdown(struct pvr2_hdw *); |
260 | 260 | ||
261 | /* toggle LED */ | ||
262 | int pvr2_led_ctrl(struct pvr2_hdw *hdw, int onoff); | ||
263 | |||
264 | /* Order decoder to reset */ | 261 | /* Order decoder to reset */ |
265 | int pvr2_hdw_cmd_decoder_reset(struct pvr2_hdw *); | 262 | int pvr2_hdw_cmd_decoder_reset(struct pvr2_hdw *); |
266 | 263 | ||