From 53b0a1c60bcc167534b31f56adfbbe2919e6f80b Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 9 Jan 2006 15:32:39 -0200 Subject: V4L/DVB (3275): Split msp3400.c into msp3400-driver.c and msp3400-kthreads.c - Split msp3400.c into msp3400-driver.c and msp3400-kthreads.c. - Removed experimental DFPREG ioctls. If this is really needed one day then it should be implemented using VIDIOC_G/S_REGISTER. - Added missing BALANCE control info for VIDIOC_QUERYCTRL. - Still more cleanup, clarified some kernel messages. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/msp3400.h | 127 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 120 insertions(+), 7 deletions(-) (limited to 'drivers/media/video/msp3400.h') diff --git a/drivers/media/video/msp3400.h b/drivers/media/video/msp3400.h index 2d9ff40f0b0..33d64ac75d3 100644 --- a/drivers/media/video/msp3400.h +++ b/drivers/media/video/msp3400.h @@ -6,22 +6,62 @@ /* ---------------------------------------------------------------------- */ -struct msp_dfpreg { - int reg; - int value; -}; +#define msp_err(fmt, arg...) \ + printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->driver.name, \ + i2c_adapter_id(client->adapter), client->addr , ## arg) +#define msp_warn(fmt, arg...) \ + printk(KERN_WARNING "%s %d-%04x: " fmt, client->driver->driver.name, \ + i2c_adapter_id(client->adapter), client->addr , ## arg) +#define msp_info(fmt, arg...) \ + printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->driver.name, \ + i2c_adapter_id(client->adapter), client->addr , ## arg) + +/* level 1 debug. */ +#define msp_dbg1(fmt, arg...) \ + do { \ + if (debug) \ + printk(KERN_INFO "%s debug %d-%04x: " fmt, client->driver->driver.name, \ + i2c_adapter_id(client->adapter), client->addr , ## arg); \ + } while (0) + +/* level 2 debug. */ +#define msp_dbg2(fmt, arg...) \ + do { \ + if (debug >= 2) \ + printk(KERN_INFO "%s debug %d-%04x: " fmt, client->driver->name, \ + i2c_adapter_id(client->adapter), client->addr , ## arg); \ + } while (0) + +/* level 3 debug. Use with care. */ +#define msp_dbg3(fmt, arg...) \ + do { \ + if (debug >= 16) \ + printk(KERN_INFO "%s debug %d-%04x: " fmt, client->driver->name, \ + i2c_adapter_id(client->adapter), client->addr , ## arg); \ + } while (0) struct msp_matrix { int input; int output; }; -#define MSP_SET_DFPREG _IOW('m',15,struct msp_dfpreg) -#define MSP_GET_DFPREG _IOW('m',16,struct msp_dfpreg) - /* ioctl for MSP_SET_MATRIX will have to be registered */ #define MSP_SET_MATRIX _IOW('m',17,struct msp_matrix) +/* This macro is allowed for *constants* only, gcc must calculate it + at compile time. Remember -- no floats in kernel mode */ +#define MSP_CARRIER(freq) ((int)((float)(freq / 18.432) * (1 << 24))) + +#define MSP_MODE_AM_DETECT 0 +#define MSP_MODE_FM_RADIO 2 +#define MSP_MODE_FM_TERRA 3 +#define MSP_MODE_FM_SAT 4 +#define MSP_MODE_FM_NICAM1 5 +#define MSP_MODE_FM_NICAM2 6 +#define MSP_MODE_AM_NICAM 7 +#define MSP_MODE_BTSC 8 +#define MSP_MODE_EXTERN 9 + #define SCART_MASK 0 #define SCART_IN1 1 #define SCART_IN2 2 @@ -36,4 +76,77 @@ struct msp_matrix { #define SCART1_OUT 1 #define SCART2_OUT 2 +#define OPMODE_AUTO -1 +#define OPMODE_MANUAL 0 +#define OPMODE_AUTODETECT 1 /* use autodetect (>= msp3410 only) */ +#define OPMODE_AUTOSELECT 2 /* use autodetect & autoselect (>= msp34xxG) */ + +/* module parameters */ +extern int debug; +extern int once; +extern int amsound; +extern int standard; +extern int dolby; +extern int stereo_threshold; + +struct msp_state { + int rev1, rev2; + + int opmode; + int mode; + int norm; + int stereo; + int nicam_on; + int acb; + int in_scart; + int i2s_mode; + int main, second; /* sound carrier */ + int input; + int source; /* see msp34xxg_set_source */ + + /* v4l2 */ + int audmode; + int rxsubchans; + + int muted; + int volume, balance; + int bass, treble; + + /* thread */ + struct task_struct *kthread; + wait_queue_head_t wq; + int restart:1; + int watch_stereo:1; +}; + +#define VIDEO_MODE_RADIO 16 /* norm magic for radio mode */ + +#define HAVE_NICAM(state) (((state->rev2 >> 8) & 0xff) != 0) +#define HAVE_RADIO(state) ((state->rev1 & 0x0f) >= 'G'-'@') + +/* msp3400-driver.c */ +int msp_write_dem(struct i2c_client *client, int addr, int val); +int msp_write_dsp(struct i2c_client *client, int addr, int val); +int msp_read_dem(struct i2c_client *client, int addr); +int msp_read_dsp(struct i2c_client *client, int addr); +int msp_reset(struct i2c_client *client); +void msp_set_scart(struct i2c_client *client, int in, int out); +void msp_set_mute(struct i2c_client *client); +void msp_set_audio(struct i2c_client *client); +int msp_modus(struct i2c_client *client, int norm); +int msp_standard(int norm); +int msp_sleep(struct msp_state *state, int timeout); + +/* msp3400-kthreads.c */ +const char *msp_standard_mode_name(int mode); +void msp3400c_setcarrier(struct i2c_client *client, int cdo1, int cdo2); +void msp3400c_setmode(struct i2c_client *client, int type); +void msp3400c_setstereo(struct i2c_client *client, int mode); +int autodetect_stereo(struct i2c_client *client); +int msp3400c_thread(void *data); +int msp3410d_thread(void *data); +int msp34xxg_thread(void *data); +void msp34xxg_detect_stereo(struct i2c_client *client); +void msp34xxg_set_audmode(struct i2c_client *client, int audmode); + #endif /* MSP3400_H */ -- cgit From 7e8b09ea1636e360a8fabebeaeb91c17f64e01b5 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 9 Jan 2006 15:32:40 -0200 Subject: V4L/DVB (3276): Added new diagnositics macros, convert msp3400 to the new macros. - Added new v4l_err, v4l_warn, v4l_info and v4l_dbg macros to v4l2-common.h for use in v4l-dvb i2c drivers. This ensures a unique prefix for each device instance. - At a later stage these macros may be reimplemented using the device-generic macros from device.h. - Converted the msp3400 driver to the new macros. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/msp3400.h | 34 ---------------------------------- 1 file changed, 34 deletions(-) (limited to 'drivers/media/video/msp3400.h') diff --git a/drivers/media/video/msp3400.h b/drivers/media/video/msp3400.h index 33d64ac75d3..a88a22e37e6 100644 --- a/drivers/media/video/msp3400.h +++ b/drivers/media/video/msp3400.h @@ -6,40 +6,6 @@ /* ---------------------------------------------------------------------- */ -#define msp_err(fmt, arg...) \ - printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->driver.name, \ - i2c_adapter_id(client->adapter), client->addr , ## arg) -#define msp_warn(fmt, arg...) \ - printk(KERN_WARNING "%s %d-%04x: " fmt, client->driver->driver.name, \ - i2c_adapter_id(client->adapter), client->addr , ## arg) -#define msp_info(fmt, arg...) \ - printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->driver.name, \ - i2c_adapter_id(client->adapter), client->addr , ## arg) - -/* level 1 debug. */ -#define msp_dbg1(fmt, arg...) \ - do { \ - if (debug) \ - printk(KERN_INFO "%s debug %d-%04x: " fmt, client->driver->driver.name, \ - i2c_adapter_id(client->adapter), client->addr , ## arg); \ - } while (0) - -/* level 2 debug. */ -#define msp_dbg2(fmt, arg...) \ - do { \ - if (debug >= 2) \ - printk(KERN_INFO "%s debug %d-%04x: " fmt, client->driver->name, \ - i2c_adapter_id(client->adapter), client->addr , ## arg); \ - } while (0) - -/* level 3 debug. Use with care. */ -#define msp_dbg3(fmt, arg...) \ - do { \ - if (debug >= 16) \ - printk(KERN_INFO "%s debug %d-%04x: " fmt, client->driver->name, \ - i2c_adapter_id(client->adapter), client->addr , ## arg); \ - } while (0) - struct msp_matrix { int input; int output; -- cgit From 7560d7a4f9add362d60d4513033cf522c37adeea Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 9 Jan 2006 18:21:32 -0200 Subject: V4L/DVB (3317): msp3400: use v4l2_std_id and determine chip capabilities. - Replace old norm by the v4l2_std_id values. - Add code to correctly detect the various capabilities of the various msp chips. It's not yet used, that's going to be the next step. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/msp3400.h | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'drivers/media/video/msp3400.h') diff --git a/drivers/media/video/msp3400.h b/drivers/media/video/msp3400.h index a88a22e37e6..70327506f89 100644 --- a/drivers/media/video/msp3400.h +++ b/drivers/media/video/msp3400.h @@ -57,10 +57,21 @@ extern int stereo_threshold; struct msp_state { int rev1, rev2; - + int has_nicam; + int has_radio; + int has_headphones; + int has_ntsc_jp_d_k3; + int has_scart4; + int has_scart23_in_scart2_out; + int has_subwoofer; + int has_sound_processing; + int has_virtual_dolby_surround; + int has_dolby_pro_logic; + + int radio; int opmode; int mode; - int norm; + v4l2_std_id std; int stereo; int nicam_on; int acb; @@ -85,11 +96,6 @@ struct msp_state { int watch_stereo:1; }; -#define VIDEO_MODE_RADIO 16 /* norm magic for radio mode */ - -#define HAVE_NICAM(state) (((state->rev2 >> 8) & 0xff) != 0) -#define HAVE_RADIO(state) ((state->rev1 & 0x0f) >= 'G'-'@') - /* msp3400-driver.c */ int msp_write_dem(struct i2c_client *client, int addr, int val); int msp_write_dsp(struct i2c_client *client, int addr, int val); @@ -99,8 +105,7 @@ int msp_reset(struct i2c_client *client); void msp_set_scart(struct i2c_client *client, int in, int out); void msp_set_mute(struct i2c_client *client); void msp_set_audio(struct i2c_client *client); -int msp_modus(struct i2c_client *client, int norm); -int msp_standard(int norm); +int msp_modus(struct i2c_client *client); int msp_sleep(struct msp_state *state, int timeout); /* msp3400-kthreads.c */ -- cgit From d312a46e5340be6a89c662ac483230c0737148c9 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 9 Jan 2006 18:21:36 -0200 Subject: V4L/DVB (3324): msp3400 audio handling bug fixes. - Check capabilities for audio settings (volume, balance, bass, treble, loudness, mute) - added loudness support - added missing VIDEO_AUDIO_BALANCE flags for v4l1 compatibility - do not call msp_any_detect_stereo for non-autoselect chips to retrieve the current stereo setting: that will temporarily mute the sound. It is only needed when the stereo mode might be changed, and for autoselect msp processors that do not periodically need to update their stereo setting. - do not wake up the thread if the standard did not change. Prevents temporary audio drop-out if the standard is set to the same value. - fix confused stereo detect code where V4L2_TUNER_SUB_STEREO and V4L2_TUNER_MODE_STEREO values were used incorrectly. - stereo mode reporting was broken (v4l2 value used to index a string array expecting v4l1 mode values). - do not set dsp register 0x30 in the 3410d thread: that register does not exist for pre-'G' revision msp chips. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/msp3400.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/media/video/msp3400.h') diff --git a/drivers/media/video/msp3400.h b/drivers/media/video/msp3400.h index 70327506f89..fb44eef5d51 100644 --- a/drivers/media/video/msp3400.h +++ b/drivers/media/video/msp3400.h @@ -63,6 +63,7 @@ struct msp_state { int has_ntsc_jp_d_k3; int has_scart4; int has_scart23_in_scart2_out; + int has_scart2_out_volume; int has_subwoofer; int has_sound_processing; int has_virtual_dolby_surround; @@ -72,7 +73,6 @@ struct msp_state { int opmode; int mode; v4l2_std_id std; - int stereo; int nicam_on; int acb; int in_scart; @@ -85,8 +85,8 @@ struct msp_state { int audmode; int rxsubchans; - int muted; - int volume, balance; + int volume, muted; + int balance, loudness; int bass, treble; /* thread */ -- cgit From 5af0c8f6a09534ebc6c56b4e5d79d0d521364750 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 9 Jan 2006 18:21:37 -0200 Subject: V4L/DVB (3326): Fix stereo and standard reporting of msp3400 (esp. for radio) - Add VIDIOC_LOG_STATUS to the radio device ioctl list. - Reduce the confusion between modes and standards - Fix stereo reporting for radio. - Don't set i2c configuration if the chip doesn't support it. - Fix reporting of current standard for radio. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/msp3400.h | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'drivers/media/video/msp3400.h') diff --git a/drivers/media/video/msp3400.h b/drivers/media/video/msp3400.h index fb44eef5d51..8a05cf500a8 100644 --- a/drivers/media/video/msp3400.h +++ b/drivers/media/video/msp3400.h @@ -57,22 +57,24 @@ extern int stereo_threshold; struct msp_state { int rev1, rev2; - int has_nicam; - int has_radio; - int has_headphones; - int has_ntsc_jp_d_k3; - int has_scart4; - int has_scart23_in_scart2_out; - int has_scart2_out_volume; - int has_subwoofer; - int has_sound_processing; - int has_virtual_dolby_surround; - int has_dolby_pro_logic; + u8 has_nicam; + u8 has_radio; + u8 has_headphones; + u8 has_ntsc_jp_d_k3; + u8 has_scart4; + u8 has_scart23_in_scart2_out; + u8 has_scart2_out_volume; + u8 has_i2s_conf; + u8 has_subwoofer; + u8 has_sound_processing; + u8 has_virtual_dolby_surround; + u8 has_dolby_pro_logic; int radio; int opmode; + int std; int mode; - v4l2_std_id std; + v4l2_std_id v4l2_std; int nicam_on; int acb; int in_scart; @@ -109,7 +111,7 @@ int msp_modus(struct i2c_client *client); int msp_sleep(struct msp_state *state, int timeout); /* msp3400-kthreads.c */ -const char *msp_standard_mode_name(int mode); +const char *msp_standard_std_name(int std); void msp3400c_setcarrier(struct i2c_client *client, int cdo1, int cdo2); void msp3400c_setmode(struct i2c_client *client, int type); void msp3400c_setstereo(struct i2c_client *client, int mode); -- cgit From f167cb4e6ee07914b66eb85fc0bf006a409b6838 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 11 Jan 2006 19:41:49 -0200 Subject: V4L/DVB (3345): Fixes some bad global variables - Debug global var is already used inside kernel. - v4l_dbg now expects the debug var - global vars inside msp34xx renamed to msp_* Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/msp3400.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/media/video/msp3400.h') diff --git a/drivers/media/video/msp3400.h b/drivers/media/video/msp3400.h index 8a05cf500a8..70a5ef8ba01 100644 --- a/drivers/media/video/msp3400.h +++ b/drivers/media/video/msp3400.h @@ -48,12 +48,12 @@ struct msp_matrix { #define OPMODE_AUTOSELECT 2 /* use autodetect & autoselect (>= msp34xxG) */ /* module parameters */ -extern int debug; -extern int once; -extern int amsound; -extern int standard; -extern int dolby; -extern int stereo_threshold; +extern int msp_debug; +extern int msp_once; +extern int msp_amsound; +extern int msp_standard; +extern int msp_dolby; +extern int msp_stereo_thresh; struct msp_state { int rev1, rev2; -- cgit From 27487d44712aaa37710cc508d5bd6119f5e9f976 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Sun, 15 Jan 2006 15:04:52 -0200 Subject: V4L/DVB (3384): Separate tv & radio freqs, fix cb/freq transmit order for tuners that need this. - Moved MSP_SET_MATRIX to v4l2-common.h - Fix typos and integer overflows in tea5767.c - Split old freq field into a tv_freq and a radio_freq. Prevents that a radio tuner is initialized with a tv frequency or vice versa. - When switching to radio mode initialize the tuner with the last used radio frequency (this was already done for the TV mode). As a result of these changes the tuner module now remembers the last set radio and TV frequencies, which is what you would expect to happen. - Move out of range frequencies to the closest valid frequency as per v4l2 API spec. - Fix incorrect initial radio frequency (multiplier is 16000, not 16) - Add boundary check for out of range frequencies. - Use new flag to check if the order of the CB and freq. depends on the last set frequency. That is needed for some tuners or you can get static as a result. The flag is added for those tuners where I know that the datasheet indicates that this is necessary. - For this new check use the last set div value, not the last frequency as radio frequencies are always much higher due to the 16000 multiplier. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/msp3400.h | 8 -------- 1 file changed, 8 deletions(-) (limited to 'drivers/media/video/msp3400.h') diff --git a/drivers/media/video/msp3400.h b/drivers/media/video/msp3400.h index 70a5ef8ba01..a9ac57d0700 100644 --- a/drivers/media/video/msp3400.h +++ b/drivers/media/video/msp3400.h @@ -6,14 +6,6 @@ /* ---------------------------------------------------------------------- */ -struct msp_matrix { - int input; - int output; -}; - -/* ioctl for MSP_SET_MATRIX will have to be registered */ -#define MSP_SET_MATRIX _IOW('m',17,struct msp_matrix) - /* This macro is allowed for *constants* only, gcc must calculate it at compile time. Remember -- no floats in kernel mode */ #define MSP_CARRIER(freq) ((int)((float)(freq / 18.432) * (1 << 24))) -- cgit