aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorPantelis Koukousoulas <pakt223@freemail.gr>2006-12-27 21:05:19 -0500
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-02-21 10:34:21 -0500
commit275b2e283b139bee19e7de5929d01484b8e3ee51 (patch)
treedbef39c440161762a14d119486dbc1fcd99c4455 /drivers/media
parent0b600512860cab5a0bb4647f5f726a91bce2633c (diff)
V4L/DVB (5034): Pvrusb2: Enable radio mode round #1
This is the logic that supports switching modes via e.g., echo radio > /sys/class/pvrusb2/sn-*/ctl_input/cur_val. To do the mode switching we need to: a) broadcast AUDC_SET_RADIO and b) issue the CX2341X_ENC_MUTE_VIDEO command to the encoder. The first is done by adding a new pvr2_i2c_op and having it trigger on input change, the second by adding this command in pvr2_encoder_start() and requesting an encoder restart on input change by setting stale_subsys_mask appropriately. The clues about AUDC_SET_RADIO and CX2341X_ENC_MUTE_VIDEO were kindly provided by Hans Verkuil on the pvrusb2 mailing list. The idea to implement mode switching this way (on input change) is due to Mike Isely. Why AUDC_SET_RADIO/VIDIOC_S_STD are used for switching? I can 't be sure, but I think this can be traced to a cornell student being the first to implement radio support in ivtv "as a different standard". I think the rest just evolved from there (it 's in the ivtv ML archives). Signed-off-by: Pantelis Koukousoulas <pakt223@freemail.gr> Signed-off-by: Mike Isely <isely@pobox.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-encoder.c3
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.c7
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-i2c-chips-v4l2.c5
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-i2c-cmd-v4l2.c31
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-i2c-cmd-v4l2.h1
5 files changed, 44 insertions, 3 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-encoder.c b/drivers/media/video/pvrusb2/pvrusb2-encoder.c
index c94f97b79392..d094cac9f7a5 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-encoder.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-encoder.c
@@ -360,6 +360,9 @@ int pvr2_encoder_start(struct pvr2_hdw *hdw)
360 pvr2_hdw_gpio_chg_dir(hdw,0xffffffff,0x00000481); 360 pvr2_hdw_gpio_chg_dir(hdw,0xffffffff,0x00000481);
361 pvr2_hdw_gpio_chg_out(hdw,0xffffffff,0x00000000); 361 pvr2_hdw_gpio_chg_out(hdw,0xffffffff,0x00000000);
362 362
363 pvr2_encoder_vcmd(hdw,CX2341X_ENC_MUTE_VIDEO,1,
364 hdw->input_val == PVR2_CVAL_INPUT_RADIO ? 1 : 0);
365
363 if (hdw->config == pvr2_config_vbi) { 366 if (hdw->config == pvr2_config_vbi) {
364 status = pvr2_encoder_vcmd(hdw,CX2341X_ENC_START_CAPTURE,2, 367 status = pvr2_encoder_vcmd(hdw,CX2341X_ENC_START_CAPTURE,2,
365 0x01,0x14); 368 0x01,0x14);
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
index 503255cebc2e..5f6ab998bbe7 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
@@ -2260,6 +2260,13 @@ static int pvr2_hdw_commit_ctl_internal(struct pvr2_hdw *hdw)
2260 stale_subsys_mask |= (1<<PVR2_SUBSYS_B_ENC_CFG); 2260 stale_subsys_mask |= (1<<PVR2_SUBSYS_B_ENC_CFG);
2261 } 2261 }
2262 2262
2263 if (hdw->input_dirty) {
2264 /* pk: If input changes to or from radio, then the encoder
2265 needs to be restarted (for ENC_MUTE_VIDEO to work) */
2266 stale_subsys_mask |= (1<<PVR2_SUBSYS_B_ENC_RUN);
2267 }
2268
2269
2263 if (hdw->srate_dirty) { 2270 if (hdw->srate_dirty) {
2264 /* Write new sample rate into control structure since 2271 /* Write new sample rate into control structure since
2265 * the master copy is stale. We must track srate 2272 * the master copy is stale. We must track srate
diff --git a/drivers/media/video/pvrusb2/pvrusb2-i2c-chips-v4l2.c b/drivers/media/video/pvrusb2/pvrusb2-i2c-chips-v4l2.c
index 05121666b9ba..93b8d077c11e 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-i2c-chips-v4l2.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-i2c-chips-v4l2.c
@@ -39,6 +39,7 @@
39#define OP_AUDIORATE 4 39#define OP_AUDIORATE 4
40#define OP_SIZE 5 40#define OP_SIZE 5
41#define OP_LOG 6 41#define OP_LOG 6
42#define OP_RADIO 7
42 43
43static const struct pvr2_i2c_op * const ops[] = { 44static const struct pvr2_i2c_op * const ops[] = {
44 [OP_STANDARD] = &pvr2_i2c_op_v4l2_standard, 45 [OP_STANDARD] = &pvr2_i2c_op_v4l2_standard,
@@ -47,6 +48,7 @@ static const struct pvr2_i2c_op * const ops[] = {
47 [OP_FREQ] = &pvr2_i2c_op_v4l2_frequency, 48 [OP_FREQ] = &pvr2_i2c_op_v4l2_frequency,
48 [OP_SIZE] = &pvr2_i2c_op_v4l2_size, 49 [OP_SIZE] = &pvr2_i2c_op_v4l2_size,
49 [OP_LOG] = &pvr2_i2c_op_v4l2_log, 50 [OP_LOG] = &pvr2_i2c_op_v4l2_log,
51 [OP_RADIO] = &pvr2_i2c_op_v4l2_radio,
50}; 52};
51 53
52void pvr2_i2c_probe(struct pvr2_hdw *hdw,struct pvr2_i2c_client *cp) 54void pvr2_i2c_probe(struct pvr2_hdw *hdw,struct pvr2_i2c_client *cp)
@@ -58,7 +60,8 @@ void pvr2_i2c_probe(struct pvr2_hdw *hdw,struct pvr2_i2c_client *cp)
58 (1 << OP_VOLUME) | 60 (1 << OP_VOLUME) |
59 (1 << OP_FREQ) | 61 (1 << OP_FREQ) |
60 (1 << OP_SIZE) | 62 (1 << OP_SIZE) |
61 (1 << OP_LOG)); 63 (1 << OP_LOG) |
64 (1 << OP_RADIO));
62 65
63 if (id == I2C_DRIVERID_MSP3400) { 66 if (id == I2C_DRIVERID_MSP3400) {
64 if (pvr2_i2c_msp3400_setup(hdw,cp)) { 67 if (pvr2_i2c_msp3400_setup(hdw,cp)) {
diff --git a/drivers/media/video/pvrusb2/pvrusb2-i2c-cmd-v4l2.c b/drivers/media/video/pvrusb2/pvrusb2-i2c-cmd-v4l2.c
index 05ea17afe903..50fcceb15d51 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-i2c-cmd-v4l2.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-i2c-cmd-v4l2.c
@@ -24,7 +24,7 @@
24#include "pvrusb2-hdw-internal.h" 24#include "pvrusb2-hdw-internal.h"
25#include "pvrusb2-debug.h" 25#include "pvrusb2-debug.h"
26#include <linux/videodev2.h> 26#include <linux/videodev2.h>
27 27#include <media/v4l2-common.h> /* AUDC_SET_RADIO */
28 28
29static void set_standard(struct pvr2_hdw *hdw) 29static void set_standard(struct pvr2_hdw *hdw)
30{ 30{
@@ -50,6 +50,32 @@ const struct pvr2_i2c_op pvr2_i2c_op_v4l2_standard = {
50}; 50};
51 51
52 52
53static void set_radio(struct pvr2_hdw *hdw)
54{
55 pvr2_trace(PVR2_TRACE_CHIPS,
56 "i2c v4l2 set_radio()");
57
58 if (hdw->input_val == PVR2_CVAL_INPUT_RADIO) {
59 pvr2_i2c_core_cmd(hdw,AUDC_SET_RADIO,NULL);
60 } else {
61 set_standard(hdw);
62 }
63}
64
65
66static int check_radio(struct pvr2_hdw *hdw)
67{
68 return hdw->input_dirty != 0;
69}
70
71
72const struct pvr2_i2c_op pvr2_i2c_op_v4l2_radio = {
73 .check = check_radio,
74 .update = set_radio,
75 .name = "v4l2_radio",
76};
77
78
53static void set_bcsh(struct pvr2_hdw *hdw) 79static void set_bcsh(struct pvr2_hdw *hdw)
54{ 80{
55 struct v4l2_control ctrl; 81 struct v4l2_control ctrl;
@@ -145,7 +171,8 @@ static void set_frequency(struct pvr2_hdw *hdw)
145 memset(&freq,0,sizeof(freq)); 171 memset(&freq,0,sizeof(freq));
146 freq.frequency = fv / 62500; 172 freq.frequency = fv / 62500;
147 freq.tuner = 0; 173 freq.tuner = 0;
148 freq.type = V4L2_TUNER_ANALOG_TV; 174 freq.type = (hdw->input_val == PVR2_CVAL_INPUT_RADIO) ?
175 V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
149 pvr2_i2c_core_cmd(hdw,VIDIOC_S_FREQUENCY,&freq); 176 pvr2_i2c_core_cmd(hdw,VIDIOC_S_FREQUENCY,&freq);
150} 177}
151 178
diff --git a/drivers/media/video/pvrusb2/pvrusb2-i2c-cmd-v4l2.h b/drivers/media/video/pvrusb2/pvrusb2-i2c-cmd-v4l2.h
index ecabddba1ec5..894de610893b 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-i2c-cmd-v4l2.h
+++ b/drivers/media/video/pvrusb2/pvrusb2-i2c-cmd-v4l2.h
@@ -26,6 +26,7 @@
26#include "pvrusb2-i2c-core.h" 26#include "pvrusb2-i2c-core.h"
27 27
28extern const struct pvr2_i2c_op pvr2_i2c_op_v4l2_standard; 28extern const struct pvr2_i2c_op pvr2_i2c_op_v4l2_standard;
29extern const struct pvr2_i2c_op pvr2_i2c_op_v4l2_radio;
29extern const struct pvr2_i2c_op pvr2_i2c_op_v4l2_bcsh; 30extern const struct pvr2_i2c_op pvr2_i2c_op_v4l2_bcsh;
30extern const struct pvr2_i2c_op pvr2_i2c_op_v4l2_volume; 31extern const struct pvr2_i2c_op pvr2_i2c_op_v4l2_volume;
31extern const struct pvr2_i2c_op pvr2_i2c_op_v4l2_frequency; 32extern const struct pvr2_i2c_op pvr2_i2c_op_v4l2_frequency;