ivtv: zero-initialize cx25840 platform data
Subsystems (3)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v6 1/6 ivtv: zero-initialize cx25840 platform data
We need to zero-initialize cx25840 platform data structure to make sure that its future members do not contain random stack garbage.
--- drivers/media/pci/ivtv/ivtv-i2c.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/pci/ivtv/ivtv-i2c.c +1 -0
@@ -293,6 +293,7 @@ int ivtv_i2c_register(struct ivtv *itv, unsigned idx) .platform_data = &pdata, }; +memset (&pdata,0 ,sizeof (pdata)); pdata.pvr150_workaround = itv->pvr150_workaround; sd =v4l2_i2c_new_subdev_board (&itv->v4l2_dev, adap, &cx25840_info,NULL );
PATCH v6 2/6 cx25840: add kernel-doc description of struct cx25840_state
In reply to a message not in the archiveThis commit describes a device instance private data of the driver (struct cx25840_state) in a kernel-doc style comment.
--- drivers/media/i2c/cx25840/cx25840-core.h | 33 ++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-)
drivers/media/i2c/cx25840/cx25840-core.h +31 -2
@@ -45,6 +45,35 @@ enum cx25840_media_pads {CX25840_NUM_PADS }; +/** +* struct cx25840_state - a device instance private data +* @c: i2c_client struct representing this device +* @sd: our V4L2 sub-device +* @hdl: our V4L2 control handler +* @volume: audio volume V4L2 control (non-cx2583x devices only) +* @mute: audio mute V4L2 control (non-cx2583x devices only) +* @pvr150_workaround: whether we enable workaround for Hauppauge PVR150 +* hardware bug (audio dropping out) +* @radio: set if we are currently in the radio mode, otherwise +* the current mode is non-radio (that is, video) +* @std: currently set video standard +* @vid_input: currently set video input +* @aud_input: currently set audio input +* @audclk_freq: currently set audio sample rate +* @audmode: currently set audio mode (when in non-radio mode) +* @vbi_line_offset: vbi line number offset +* @id: exact device model +* @rev: raw device id read from the chip +* @is_initialized: whether we have already loaded firmware into the chip +* and initialized it +* @vbi_regs_offset: offset of vbi regs +* @fw_wait: wait queue to wake an initalization function up when +* firmware loading (on a separate workqueue) finishes +* @fw_work: a work that actually loads the firmware on a separate +* workqueue +* @ir_state: a pointer to chip IR controller private data +* @pads: array of supported chip pads (currently only a stub) +*/ struct cx25840_state {struct i2c_client *c;struct v4l2_subdev sd;
@@ -66,8 +95,8 @@ struct cx25840_state {u32 rev;int is_initialized;unsigned vbi_regs_offset; -wait_queue_head_t fw_wait;/* wake up when the fw load is finished */ -struct work_struct fw_work;/* work entry for fw load */ +wait_queue_head_t fw_wait; +struct work_struct fw_work;struct cx25840_ir_state *ir_state;#if defined(CONFIG_MEDIA_CONTROLLER )struct media_pad pads[CX25840_NUM_PADS ];
PATCH v6 3/6 cx25840: add pin to pad mapping and output format configuration
In reply to a message not in the archiveThis commit adds pin to pad mapping and output format configuration support in CX2584x-series chips to cx25840 driver.
This functionality is then used to allow disabling ivtv-specific hacks (called a "generic mode"), so cx25840 driver can be used for other devices not needing them without risking compatibility problems.
--- drivers/media/i2c/cx25840/cx25840-core.c | 396 ++++++++++++++++++++++++++++++- drivers/media/i2c/cx25840/cx25840-core.h | 13 + drivers/media/i2c/cx25840/cx25840-vbi.c | 3 + include/media/drv-intf/cx25840.h | 74 +++++- 4 files changed, 484 insertions(+), 2 deletions(-)
drivers/media/i2c/cx25840/cx25840-core.c +395 -1
@@ -21,6 +21,9 @@* CX23888 DIF support for the HVR1850 * Copyright (C) 2011 Steven Toth <[email protected]> * +* CX2584x pin to pad mapping and output format configuration support are +* Copyright (C) 2011 Maciej S. Szmigiero <[email protected]> +* * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2
@@ -316,6 +319,260 @@ static int cx23885_s_io_pin_config(struct v4l2_subdev *sd, size_t n,return 0 ; } +static u8 cx25840_function_to_pad (struct i2c_client *client,u8 function) +{ +switch (function) { +case CX25840_PAD_ACTIVE : +return 1 ; + +case CX25840_PAD_VACTIVE : +return 2 ; + +case CX25840_PAD_CBFLAG : +return 3 ; + +case CX25840_PAD_VID_DATA_EXT0 : +return 4 ; + +case CX25840_PAD_VID_DATA_EXT1 : +return 5 ; + +case CX25840_PAD_GPO0 : +return 6 ; + +case CX25840_PAD_GPO1 : +return 7 ; + +case CX25840_PAD_GPO2 : +return 8 ; + +case CX25840_PAD_GPO3 : +return 9 ; + +case CX25840_PAD_IRQ_N : +return 10 ; + +case CX25840_PAD_AC_SYNC : +return 11 ; + +case CX25840_PAD_AC_SDOUT : +return 12 ; + +case CX25840_PAD_PLL_CLK : +return 13 ; + +case CX25840_PAD_VRESET : +return 14 ; + +default : +if (function !=CX25840_PAD_DEFAULT ) +v4l_err (client, +"invalid function %u, assuming default\n" , + (unsigned int )function); +return 0 ; + } +} + +static void cx25840_set_invert (u8 *pinctrl3,u8 *voutctrl4,u8 function, +u8 pin,bool invert) +{ +switch (function) { +case CX25840_PAD_IRQ_N : +if (invert) + *pinctrl3 &= ~2 ; +else + *pinctrl3 |=2 ; +break ; + +case CX25840_PAD_ACTIVE : +if (invert) + *voutctrl4 |=BIT (2 ); +else + *voutctrl4 &= ~BIT (2 ); +break ; + +case CX25840_PAD_VACTIVE : +if (invert) + *voutctrl4 |=BIT (5 ); +else + *voutctrl4 &= ~BIT (5 ); +break ; + +case CX25840_PAD_CBFLAG : +if (invert) + *voutctrl4 |=BIT (4 ); +else + *voutctrl4 &= ~BIT (4 ); +break ; + +case CX25840_PAD_VRESET : +if (invert) + *voutctrl4 |=BIT (0 ); +else + *voutctrl4 &= ~BIT (0 ); +break ; + } + +if (function !=CX25840_PAD_DEFAULT ) +return ; + +switch (pin) { +case CX25840_PIN_DVALID_PRGM0 : +if (invert) + *voutctrl4 |=BIT (6 ); +else + *voutctrl4 &= ~BIT (6 ); +break ; + +case CX25840_PIN_HRESET_PRGM2 : +if (invert) + *voutctrl4 |=BIT (1 ); +else + *voutctrl4 &= ~BIT (1 ); +break ; + } +} + +static int cx25840_s_io_pin_config (struct v4l2_subdev *sd,size_t n, +struct v4l2_subdev_io_pin_config *p) +{ +struct i2c_client *client =v4l2_get_subdevdata (sd); +unsigned int i; +u8 pinctrl[6 ], pinconf[10 ], voutctrl4; + +for (i =0 ; i <6 ; i++) + pinctrl[i] =cx25840_read (client,0x114 + i); + +for (i =0 ; i <10 ; i++) + pinconf[i] =cx25840_read (client,0x11c + i); + + voutctrl4 =cx25840_read (client,0x407 ); + +for (i =0 ; i < n; i++) { +u8 strength = p[i].strength; + +if (strength !=CX25840_PIN_DRIVE_SLOW && + strength !=CX25840_PIN_DRIVE_MEDIUM && + strength !=CX25840_PIN_DRIVE_FAST ) { + +v4l_err (client, +"invalid drive speed for pin %u (%u), assuming fast\n" , + (unsigned int )p[i].pin, + (unsigned int )strength); + + strength =CX25840_PIN_DRIVE_FAST ; + } + +switch (p[i].pin) { +case CX25840_PIN_DVALID_PRGM0 : +if (p[i].flags &V4L2_SUBDEV_IO_PIN_DISABLE ) + pinctrl[0 ] &= ~BIT (6 ); +else + pinctrl[0 ] |=BIT (6 ); + + pinconf[3 ] &=0xf0 ; + pinconf[3 ] |=cx25840_function_to_pad (client, + p[i].function); + +cx25840_set_invert (&pinctrl[3 ], &voutctrl4, + p[i].function, +CX25840_PIN_DVALID_PRGM0 , + p[i].flags & +V4L2_SUBDEV_IO_PIN_ACTIVE_LOW ); + + pinctrl[4 ] &= ~(3 <<2 );/* CX25840_PIN_DRIVE_MEDIUM */ +switch (strength) { +case CX25840_PIN_DRIVE_SLOW : + pinctrl[4 ] |=1 <<2 ; +break ; + +case CX25840_PIN_DRIVE_FAST : + pinctrl[4 ] |=2 <<2 ; +break ; + } + +break ; + +case CX25840_PIN_HRESET_PRGM2 : +if (p[i].flags &V4L2_SUBDEV_IO_PIN_DISABLE ) + pinctrl[1 ] &= ~BIT (0 ); +else + pinctrl[1 ] |=BIT (0 ); + + pinconf[4 ] &=0xf0 ; + pinconf[4 ] |=cx25840_function_to_pad (client, + p[i].function); + +cx25840_set_invert (&pinctrl[3 ], &voutctrl4, + p[i].function, +CX25840_PIN_HRESET_PRGM2 , + p[i].flags & +V4L2_SUBDEV_IO_PIN_ACTIVE_LOW ); + + pinctrl[4 ] &= ~(3 <<2 );/* CX25840_PIN_DRIVE_MEDIUM */ +switch (strength) { +case CX25840_PIN_DRIVE_SLOW : + pinctrl[4 ] |=1 <<2 ; +break ; + +case CX25840_PIN_DRIVE_FAST : + pinctrl[4 ] |=2 <<2 ; +break ; + } + +break ; + +case CX25840_PIN_PLL_CLK_PRGM7 : +if (p[i].flags &V4L2_SUBDEV_IO_PIN_DISABLE ) + pinctrl[2 ] &= ~BIT (2 ); +else + pinctrl[2 ] |=BIT (2 ); + +switch (p[i].function) { +case CX25840_PAD_XTI_X5_DLL : + pinconf[6 ] =0 ; +break ; + +case CX25840_PAD_AUX_PLL : + pinconf[6 ] =1 ; +break ; + +case CX25840_PAD_VID_PLL : + pinconf[6 ] =5 ; +break ; + +case CX25840_PAD_XTI : + pinconf[6 ] =2 ; +break ; + +default : + pinconf[6 ] =3 ; + pinconf[6 ] |= +cx25840_function_to_pad (client, + p[i].function) + <<4 ; + } + +break ; + +default : +v4l_err (client,"invalid or unsupported pin %u\n" , + (unsigned int )p[i].pin); +break ; + } + } + +cx25840_write (client,0x407 , voutctrl4); + +for (i =0 ; i <6 ; i++) +cx25840_write (client,0x114 + i, pinctrl[i]); + +for (i =0 ; i <10 ; i++) +cx25840_write (client,0x11c + i, pinconf[i]); + +return 0 ; +} +static int common_s_io_pin_config (struct v4l2_subdev *sd,size_t n,struct v4l2_subdev_io_pin_config *pincfg) {
@@ -323,6 +580,8 @@ static int common_s_io_pin_config(struct v4l2_subdev *sd, size_t n,if (is_cx2388x (state))return cx23885_s_io_pin_config (sd, n, pincfg); +else if (is_cx2584x (state)) +return cx25840_s_io_pin_config (sd, n, pincfg);return 0 ; }
@@ -455,6 +714,22 @@ static void cx25840_initialize(struct i2c_client *client)/* (re)set input */ set_input (client, state->vid_input, state->aud_input); +if (state->generic_mode) { +/* set datasheet video output defaults */ +cx25840_vconfig (client,CX25840_VCONFIG_FMT_BT656 | +CX25840_VCONFIG_RES_8BIT | +CX25840_VCONFIG_VBIRAW_DISABLED | +CX25840_VCONFIG_ANCDATA_ENABLED | +CX25840_VCONFIG_TASKBIT_ONE | +CX25840_VCONFIG_ACTIVE_HORIZONTAL | +CX25840_VCONFIG_VALID_NORMAL | +CX25840_VCONFIG_HRESETW_NORMAL | +CX25840_VCONFIG_CLKGATE_NONE | +CX25840_VCONFIG_DCMODE_DWORDS | +CX25840_VCONFIG_IDID0S_NORMAL | +CX25840_VCONFIG_VIPCLAMP_DISABLED ); + } +/* start microcontroller */ cx25840_and_or (client,0x803 , ~0x10 ,0x10 ); }
@@ -1403,7 +1678,9 @@ static int cx25840_set_fmt(struct v4l2_subdev *sd, Hsrc |= (cx25840_read (client,0x471 ) &0xf0 ) >>4 ; } - Vlines = fmt->height + (is_50Hz ?4 :7 ); + Vlines = fmt->height; +if (!state->generic_mode) + Vlines += is_50Hz ?4 :7 ;/* * We keep 1 margin for the Vsrc < Vlines check since the
@@ -1647,6 +1924,119 @@ static void log_audio_status(struct i2c_client *client) } } +#define CX25840_VCONFIG_OPTION (state, cfg_in, opt_msk) \ + do { \ + if ((cfg_in) & (opt_msk)) { \ + (state)->vid_config &= ~(opt_msk); \ + (state)->vid_config |= (cfg_in) & (opt_msk); \ + } \ + } while (0) + +#define CX25840_VCONFIG_SET_BIT (state, opt_msk, voc, idx, bit, oneval) \ + do { \ + if ((state)->vid_config & (opt_msk)) { \ + if (((state)->vid_config & (opt_msk)) == \ + (oneval)) \ + (voc)[idx] |= BIT(bit); \ + else \ + (voc)[idx] &= ~BIT(bit); \ + } \ + } while (0) + +int cx25840_vconfig (struct i2c_client *client,u32 cfg_in) +{ +struct cx25840_state *state =to_state (i2c_get_clientdata (client)); +u8 voutctrl[3 ]; +unsigned int i; + +/* apply incoming options to the current state */ +CX25840_VCONFIG_OPTION (state, cfg_in,CX25840_VCONFIG_FMT_MASK ); +CX25840_VCONFIG_OPTION (state, cfg_in,CX25840_VCONFIG_RES_MASK ); +CX25840_VCONFIG_OPTION (state, cfg_in,CX25840_VCONFIG_VBIRAW_MASK ); +CX25840_VCONFIG_OPTION (state, cfg_in,CX25840_VCONFIG_ANCDATA_MASK ); +CX25840_VCONFIG_OPTION (state, cfg_in,CX25840_VCONFIG_TASKBIT_MASK ); +CX25840_VCONFIG_OPTION (state, cfg_in,CX25840_VCONFIG_ACTIVE_MASK ); +CX25840_VCONFIG_OPTION (state, cfg_in,CX25840_VCONFIG_VALID_MASK ); +CX25840_VCONFIG_OPTION (state, cfg_in,CX25840_VCONFIG_HRESETW_MASK ); +CX25840_VCONFIG_OPTION (state, cfg_in,CX25840_VCONFIG_CLKGATE_MASK ); +CX25840_VCONFIG_OPTION (state, cfg_in,CX25840_VCONFIG_DCMODE_MASK ); +CX25840_VCONFIG_OPTION (state, cfg_in,CX25840_VCONFIG_IDID0S_MASK ); +CX25840_VCONFIG_OPTION (state, cfg_in,CX25840_VCONFIG_VIPCLAMP_MASK ); + +for (i =0 ; i <3 ; i++) + voutctrl[i] =cx25840_read (client,0x404 + i); + +/* apply state to hardware regs */ +if (state->vid_config &CX25840_VCONFIG_FMT_MASK ) + voutctrl[0 ] &= ~3 ; +switch (state->vid_config &CX25840_VCONFIG_FMT_MASK ) { +case CX25840_VCONFIG_FMT_BT656 : + voutctrl[0 ] |=1 ; +break ; + +case CX25840_VCONFIG_FMT_VIP11 : + voutctrl[0 ] |=2 ; +break ; + +case CX25840_VCONFIG_FMT_VIP2 : + voutctrl[0 ] |=3 ; +break ; + +case CX25840_VCONFIG_FMT_BT601 : +/* zero */ +default : +break ; + } + +CX25840_VCONFIG_SET_BIT (state,CX25840_VCONFIG_RES_MASK , voutctrl, +0 ,2 ,CX25840_VCONFIG_RES_10BIT ); +CX25840_VCONFIG_SET_BIT (state,CX25840_VCONFIG_VBIRAW_MASK , voutctrl, +0 ,3 ,CX25840_VCONFIG_VBIRAW_ENABLED ); +CX25840_VCONFIG_SET_BIT (state,CX25840_VCONFIG_ANCDATA_MASK , voutctrl, +0 ,4 ,CX25840_VCONFIG_ANCDATA_ENABLED ); +CX25840_VCONFIG_SET_BIT (state,CX25840_VCONFIG_TASKBIT_MASK , voutctrl, +0 ,5 ,CX25840_VCONFIG_TASKBIT_ONE ); +CX25840_VCONFIG_SET_BIT (state,CX25840_VCONFIG_ACTIVE_MASK , voutctrl, +1 ,2 ,CX25840_VCONFIG_ACTIVE_HORIZONTAL ); +CX25840_VCONFIG_SET_BIT (state,CX25840_VCONFIG_VALID_MASK , voutctrl, +1 ,3 ,CX25840_VCONFIG_VALID_ANDACTIVE ); +CX25840_VCONFIG_SET_BIT (state,CX25840_VCONFIG_HRESETW_MASK , voutctrl, +1 ,4 ,CX25840_VCONFIG_HRESETW_PIXCLK ); + +if (state->vid_config &CX25840_VCONFIG_CLKGATE_MASK ) + voutctrl[1 ] &= ~(3 <<6 ); +switch (state->vid_config &CX25840_VCONFIG_CLKGATE_MASK ) { +case CX25840_VCONFIG_CLKGATE_VALID : + voutctrl[1 ] |=2 ; +break ; + +case CX25840_VCONFIG_CLKGATE_VALIDACTIVE : + voutctrl[1 ] |=3 ; +break ; + +case CX25840_VCONFIG_CLKGATE_NONE : +/* zero */ +default : +break ; + } + + +CX25840_VCONFIG_SET_BIT (state,CX25840_VCONFIG_DCMODE_MASK , voutctrl, +2 ,0 ,CX25840_VCONFIG_DCMODE_BYTES ); +CX25840_VCONFIG_SET_BIT (state,CX25840_VCONFIG_IDID0S_MASK , voutctrl, +2 ,1 ,CX25840_VCONFIG_IDID0S_LINECNT ); +CX25840_VCONFIG_SET_BIT (state,CX25840_VCONFIG_VIPCLAMP_MASK , voutctrl, +2 ,4 ,CX25840_VCONFIG_VIPCLAMP_ENABLED ); + +for (i =0 ; i <3 ; i++) +cx25840_write (client,0x404 + i, voutctrl[i]); + +return 0 ; +} + +#undef CX25840_VCONFIG_SET_BIT +#undef CX25840_VCONFIG_OPTION +/* ----------------------------------------------------------------------- */ /* This load_fw operation must be called to load the driver's firmware.
@@ -1836,6 +2226,9 @@ static int cx25840_s_video_routing(struct v4l2_subdev *sd,if (is_cx23888 (state))cx23888_std_setup (client); +if (is_cx2584x (state) && state->generic_mode) +cx25840_vconfig (client, config); +return set_input (client, input, state->aud_input); }
@@ -5335,6 +5728,7 @@ static int cx25840_probe(struct i2c_client *client,struct cx25840_platform_data *pdata = client->dev.platform_data; state->pvr150_workaround = pdata->pvr150_workaround; + state->generic_mode = pdata->generic_mode; }cx25840_ir_probe (sd);
drivers/media/i2c/cx25840/cx25840-core.h +13 -0
@@ -54,10 +54,12 @@ enum cx25840_media_pads {* @mute: audio mute V4L2 control (non-cx2583x devices only) * @pvr150_workaround: whether we enable workaround for Hauppauge PVR150 * hardware bug (audio dropping out) +* @generic_mode: whether we disable ivtv-specific hacks * @radio: set if we are currently in the radio mode, otherwise * the current mode is non-radio (that is, video) * @std: currently set video standard * @vid_input: currently set video input +* @vid_config: currently set video output configuration * @aud_input: currently set audio input * @audclk_freq: currently set audio sample rate * @audmode: currently set audio mode (when in non-radio mode)
@@ -84,9 +86,11 @@ struct cx25840_state {struct v4l2_ctrl *mute; };int pvr150_workaround; +int generic_mode;int radio;v4l2_std_id std;enum cx25840_video_input vid_input; +u32 vid_config;enum cx25840_audio_input aud_input;u32 audclk_freq;int audmode;
@@ -119,6 +123,14 @@ static inline bool is_cx2583x(struct cx25840_state *state) state->id ==CX25837 ; } +static inline bool is_cx2584x (struct cx25840_state *state) +{ +return state->id ==CX25840 || + state->id ==CX25841 || + state->id ==CX25842 || + state->id ==CX25843 ; +} +static inline bool is_cx231xx (struct cx25840_state *state) {return state->id ==CX2310X_AV ;
@@ -156,6 +168,7 @@ int cx25840_and_or(struct i2c_client *client, u16 addr, unsigned mask, u8 value)int cx25840_and_or4 (struct i2c_client *client,u16 addr,u32 and_mask,u32 or_value);void cx25840_std_setup (struct i2c_client *client); +int cx25840_vconfig (struct i2c_client *client,u32 cfg_in);/* ----------------------------------------------------------------------- */ /* cx25850-firmware.c */
drivers/media/i2c/cx25840/cx25840-vbi.c +3 -0
@@ -95,6 +95,7 @@ int cx25840_g_sliced_fmt(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_format *memset (svbi->service_lines,0 ,sizeof (svbi->service_lines)); svbi->service_set =0 ;/* we're done if raw VBI is active */ +/* this will have to be changed for generic_mode VBI */ if ((cx25840_read (client,0x404 ) &0x10 ) ==0 )return 0 ;
@@ -137,6 +138,7 @@ int cx25840_s_raw_fmt(struct v4l2_subdev *sd, struct v4l2_vbi_format *fmt)cx25840_write (client,0x54f , vbi_offset); else cx25840_write(client, 0x47f, vbi_offset); +/* this will have to be changed for generic_mode VBI */ cx25840_write (client,0x404 ,0x2e );return 0 ; }
@@ -157,6 +159,7 @@ int cx25840_s_sliced_fmt(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_format *cx25840_std_setup (client);/* Sliced VBI */ +/* this will have to be changed for generic_mode VBI */ cx25840_write (client,0x404 ,0x32 );/* Ancillary data */ cx25840_write (client,0x406 ,0x13 );if (is_cx23888 (state))
include/media/drv-intf/cx25840.h +73 -1
88 lines not on this page · raw message
PATCH v6 4/6 tuner-simple: allow setting mono radio mode
In reply to a message not in the archiveFor some types of tuners (Philips FMD1216ME(X) MK3 currently) we know that letting TDA9887 output port 1 remain high (inactive) will switch FM radio to mono mode.
Let's make use of this functionality - nothing changes for the default stereo radio mode.
Tested on a Medion 95700 board which has a FMD1216ME tuner.
--- drivers/media/tuners/tuner-simple.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/media/tuners/tuner-simple.c +3 -2
@@ -670,6 +670,7 @@ static int simple_set_radio_freq(struct dvb_frontend *fe,int rc, j;struct tuner_params *t_params;unsigned int freq = params->frequency; +bool mono = params->audmode ==V4L2_TUNER_MODE_MONO ; tun = priv->tun;
@@ -736,8 +737,8 @@ static int simple_set_radio_freq(struct dvb_frontend *fe, config |=TDA9887_PORT2_ACTIVE ;if (t_params->intercarrier_mode) config |=TDA9887_INTERCARRIER ; -/* if (t_params->port1_set_for_fm_mono) -config &= ~TDA9887_PORT1_ACTIVE;*/ +if (t_params->port1_set_for_fm_mono && mono) + config &= ~TDA9887_PORT1_ACTIVE ;if (t_params->fm_gain_normal) config |=TDA9887_GAIN_NORMAL ;if (t_params->radio_if ==2 )
PATCH v6 5/6 cxusb: implement Medion MD95700 digital / analog coexistence
In reply to a message not in the archiveThis patch prepares cxusb driver for supporting the analog part of Medion 95700 (previously only the digital - DVB - mode was supported).
Specifically, it adds support for:
* switching the device between analog and digital modes of operation,
* enforcing that only one mode is active at the same time due to hardware limitations.
Actual implementation of the analog mode will be provided by the next commit.
--- drivers/media/usb/dvb-usb/cxusb.c | 450 +++++++++++++++++++++++++++---- drivers/media/usb/dvb-usb/cxusb.h | 48 ++++ drivers/media/usb/dvb-usb/dvb-usb-dvb.c | 20 +- drivers/media/usb/dvb-usb/dvb-usb-init.c | 13 + drivers/media/usb/dvb-usb/dvb-usb.h | 8 + 5 files changed, 486 insertions(+), 53 deletions(-)
drivers/media/usb/dvb-usb/cxusb.c +400 -50
@@ -16,6 +16,7 @@* Copyright (C) 2005 Patrick Boettcher ([email protected]) * Copyright (C) 2006 Michael Krufky ([email protected]) * Copyright (C) 2006, 2007 Chris Pascoe ([email protected]) +* Copyright (C) 2011, 2017 Maciej S. Szmigiero ([email protected]) * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free
@@ -24,9 +25,12 @@* see Documentation/dvb/README.dvb-usb for more information */ #include <media/tuner.h> -#include <linux/vmalloc.h> -#include <linux/slab.h> +#include <linux/delay.h> +#include <linux/device.h> #include <linux/kernel.h> +#include <linux/slab.h> +#include <linux/string.h> +#include <linux/vmalloc.h> #include "cxusb.h"
@@ -47,17 +51,45 @@#include "si2157.h" /* debug */ -static int dvb_usb_cxusb_debug; +int dvb_usb_cxusb_debug;module_param_named (debug, dvb_usb_cxusb_debug, int,0644 ); -MODULE_PARM_DESC (debug,"set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS ); +MODULE_PARM_DESC (debug,"set debugging level (see cxusb.h)." +DVB_USB_DEBUG_STATUS );DVB_DEFINE_MOD_OPT_ADAPTER_NR (adapter_nr); -#define deb_info(args...) dprintk(dvb_usb_cxusb_debug, 0x03, args) -#define deb_i2c(args...) dprintk(dvb_usb_cxusb_debug, 0x02, args) +#define deb_info(args...) dprintk(dvb_usb_cxusb_debug, CXUSB_DBG_MISC, args) +#define deb_i2c(args...) dprintk(dvb_usb_cxusb_debug, CXUSB_DBG_I2C, args) + +enum cxusb_table_index { +MEDION_MD95700 , +DVICO_BLUEBIRD_LG064F_COLD , +DVICO_BLUEBIRD_LG064F_WARM , +DVICO_BLUEBIRD_DUAL_1_COLD , +DVICO_BLUEBIRD_DUAL_1_WARM , +DVICO_BLUEBIRD_LGZ201_COLD , +DVICO_BLUEBIRD_LGZ201_WARM , +DVICO_BLUEBIRD_TH7579_COLD , +DVICO_BLUEBIRD_TH7579_WARM , +DIGITALNOW_BLUEBIRD_DUAL_1_COLD , +DIGITALNOW_BLUEBIRD_DUAL_1_WARM , +DVICO_BLUEBIRD_DUAL_2_COLD , +DVICO_BLUEBIRD_DUAL_2_WARM , +DVICO_BLUEBIRD_DUAL_4 , +DVICO_BLUEBIRD_DVB_T_NANO_2 , +DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM , +AVERMEDIA_VOLAR_A868R , +DVICO_BLUEBIRD_DUAL_4_REV_2 , +CONEXANT_D680_DMB , +MYGICA_D689 , +MYGICA_T230 , + NR__cxusb_table_index +}; + +static struct usb_device_id cxusb_table[]; -static int cxusb_ctrl_msg (struct dvb_usb_device *d, -u8 cmd,const u8 *wbuf,int wlen,u8 *rbuf,int rlen) +int cxusb_ctrl_msg (struct dvb_usb_device *d, +u8 cmd,const u8 *wbuf,int wlen,u8 *rbuf,int rlen) {struct cxusb_state *st = d->priv;int ret;
@@ -89,7 +121,8 @@ static void cxusb_gpio_tuner(struct dvb_usb_device *d, int onoff)struct cxusb_state *st = d->priv;u8 o[2 ], i; -if (st->gpio_write_state[GPIO_TUNER ] == onoff) +if (st->gpio_write_state[GPIO_TUNER ] == onoff && + !st->gpio_write_refresh[GPIO_TUNER ])return ; o[0 ] =GPIO_TUNER ;
@@ -100,6 +133,7 @@ static void cxusb_gpio_tuner(struct dvb_usb_device *d, int onoff)deb_info ("gpio_write failed.\n" ); st->gpio_write_state[GPIO_TUNER ] = onoff; + st->gpio_write_refresh[GPIO_TUNER ] = false; } static int cxusb_bluebird_gpio_rw(struct dvb_usb_device *d, u8 changemask,
@@ -259,7 +293,7 @@ static int cxusb_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],static u32 cxusb_i2c_func (struct i2c_adapter *adapter) { -return I2C_FUNC_I2C ; +return I2C_FUNC_I2C |I2C_FUNC_SMBUS_EMUL ; }static struct i2c_algorithm cxusb_i2c_algo = {
@@ -267,15 +301,48 @@ static struct i2c_algorithm cxusb_i2c_algo = { .functionality = cxusb_i2c_func, }; -static int cxusb_power_ctrl (struct dvb_usb_device *d,int onoff) +static int _cxusb_power_ctrl (struct dvb_usb_device *d,int onoff) {u8 b =0 ; + +deb_info ("setting power %s\n" , onoff ?"ON" :"OFF" ); +if (onoff)return cxusb_ctrl_msg (d,CMD_POWER_ON , &b,1 ,NULL ,0 );else return cxusb_ctrl_msg (d,CMD_POWER_OFF , &b,1 ,NULL ,0 ); } +static int cxusb_power_ctrl (struct dvb_usb_device *d,int onoff) +{ +bool is_medion = d->props.devices[0 ].warm_ids[0 ] == + &cxusb_table[MEDION_MD95700 ]; +int ret; + +if (is_medion && !onoff) { +struct cxusb_medion_dev *cxdev = d->priv; + +mutex_lock (&cxdev->open_lock); + +if (cxdev->open_type ==CXUSB_OPEN_ANALOG ) { +deb_info ("preventing DVB core from setting power OFF while we are in analog mode\n" ); + ret = -EBUSY ; + goto ret_unlock; + } + } + + ret =_cxusb_power_ctrl (d, onoff); + +ret_unlock: +if (is_medion && !onoff) { +struct cxusb_medion_dev *cxdev = d->priv; + +mutex_unlock (&cxdev->open_lock); + } + +return ret; +} +static int cxusb_aver_power_ctrl (struct dvb_usb_device *d,int onoff) {int ret;
@@ -353,11 +420,26 @@ static int cxusb_d680_dmb_power_ctrl(struct dvb_usb_device *d, int onoff)static int cxusb_streaming_ctrl (struct dvb_usb_adapter *adap,int onoff) { +struct dvb_usb_device *dvbdev = adap->dev; +bool is_medion = dvbdev->props.devices[0 ].warm_ids[0 ] == + &cxusb_table[MEDION_MD95700 ];u8 buf[2 ] = {0x03 ,0x00 }; + +if (is_medion && onoff) { +int ret; + + ret =cxusb_medion_get (dvbdev,CXUSB_OPEN_DIGITAL ); +if (ret !=0 ) +return ret; + } +if (onoff) -cxusb_ctrl_msg (adap->dev,CMD_STREAMING_ON , buf,2 ,NULL ,0 ); +cxusb_ctrl_msg (dvbdev,CMD_STREAMING_ON , buf,2 ,NULL ,0 );else -cxusb_ctrl_msg (adap->dev,CMD_STREAMING_OFF ,NULL ,0 ,NULL ,0 ); +cxusb_ctrl_msg (dvbdev,CMD_STREAMING_OFF ,NULL ,0 ,NULL ,0 ); + +if (is_medion && !onoff) +cxusb_medion_put (dvbdev);return 0 ; }
@@ -632,9 +714,21 @@ static struct max2165_config mygica_d689_max2165_cfg = {/* Callbacks for DVB USB */ static int cxusb_fmd1216me_tuner_attach (struct dvb_usb_adapter *adap) { +struct dvb_usb_device *dvbdev = adap->dev; +bool is_medion = dvbdev->props.devices[0 ].warm_ids[0 ] == + &cxusb_table[MEDION_MD95700 ]; +dvb_attach (simple_tuner_attach, adap->fe_adap[0 ].fe, - &adap->dev->i2c_adap,0x61 , + &dvbdev->i2c_adap,0x61 ,TUNER_PHILIPS_FMD1216ME_MK3 ); + +if (is_medion && adap->fe_adap[0 ].fe !=NULL ) +/* +* make sure that DVB core won't put to sleep (reset, really) +* tuner when we might be open in analog mode +*/ + adap->fe_adap[0 ].fe->ops.tuner_ops.sleep =NULL ; +return 0 ; }
@@ -738,20 +832,105 @@ static int cxusb_mygica_d689_tuner_attach(struct dvb_usb_adapter *adap)return (fe ==NULL ) ? -EIO :0 ; } -static int cxusb_cx22702_frontend_attach (struct dvb_usb_adapter *adap) +static int cxusb_medion_fe_ts_bus_ctrl (struct dvb_frontend *fe,int acquire) { +struct dvb_usb_adapter *adap = fe->dvb->priv; +struct dvb_usb_device *dvbdev = adap->dev; + +if (acquire) +return cxusb_medion_get (dvbdev,CXUSB_OPEN_DIGITAL ); + +cxusb_medion_put (dvbdev); + +return 0 ; +} + +static int cxusb_medion_set_mode (struct dvb_usb_device *dvbdev,bool digital) +{ +struct cxusb_state *st = dvbdev->priv; +int ret;u8 b; -if (usb_set_interface (adap->dev->udev,0 ,6 ) <0 ) -err ("set interface failed" ); +unsigned int i; + +/* +* switching mode while doing an I2C transaction often causes +* the device to crash +*/ +mutex_lock (&dvbdev->i2c_mutex); + +if (digital) { + ret =usb_set_interface (dvbdev->udev,0 ,6 ); +if (ret !=0 ) { +dev_err (&dvbdev->udev->dev, +"digital interface selection failed (%d)\n" , + ret); + goto ret_unlock; + } + }else { + ret =usb_set_interface (dvbdev->udev,0 ,1 ); +if (ret !=0 ) { +dev_err (&dvbdev->udev->dev, +"analog interface selection failed (%d)\n" , + ret); + goto ret_unlock; + } + } + +/* pipes need to be cleared after setting interface */ + ret =usb_clear_halt (dvbdev->udev,usb_rcvbulkpipe (dvbdev->udev,1 )); +if (ret !=0 ) +dev_warn (&dvbdev->udev->dev, +"clear halt on IN pipe failed (%d)\n" , + ret); + + ret =usb_clear_halt (dvbdev->udev,usb_sndbulkpipe (dvbdev->udev,1 )); +if (ret !=0 ) +dev_warn (&dvbdev->udev->dev, +"clear halt on OUT pipe failed (%d)\n" , + ret); + + ret =cxusb_ctrl_msg (dvbdev, digital ?CMD_DIGITAL :CMD_ANALOG , +NULL ,0 , &b,1 ); +if (ret !=0 ) { +dev_err (&dvbdev->udev->dev,"mode switch failed (%d)\n" , + ret); + goto ret_unlock; + } + +/* mode switch seems to reset GPIO states */ +for (i =0 ; i <ARRAY_SIZE (st->gpio_write_refresh); i++) + st->gpio_write_refresh[i] = true; -cxusb_ctrl_msg (adap->dev,CMD_DIGITAL ,NULL ,0 , &b,1 ); +ret_unlock: +mutex_unlock (&dvbdev->i2c_mutex); + +return ret; +} + +static int cxusb_cx22702_frontend_attach (struct dvb_usb_adapter *adap) +{ +struct dvb_usb_device *dvbdev = adap->dev; +bool is_medion = dvbdev->props.devices[0 ].warm_ids[0 ] == + &cxusb_table[MEDION_MD95700 ]; + +if (is_medion) { +int ret; + + ret =cxusb_medion_set_mode (dvbdev, true); +if (ret) +return ret; + } adap->fe_adap[0 ].fe =dvb_attach (cx22702_attach, &cxusb_cx22702_config, - &adap->dev->i2c_adap); -if ((adap->fe_adap[0 ].fe) !=NULL ) -return 0 ; + &dvbdev->i2c_adap); +if (adap->fe_adap[0 ].fe ==NULL ) +return -EIO ; -return -EIO ; +if (is_medion) + adap->fe_adap[0 ].fe->ops.ts_bus_ctrl = + cxusb_medion_fe_ts_bus_ctrl; + +return 0 ; }static int cxusb_lgdt3303_frontend_attach (struct dvb_usb_adapter *adap)
@@ -1311,6 +1490,101 @@ static int bluebird_patch_dvico_firmware_download(struct usb_device *udev,return -EINVAL ; } +int cxusb_medion_get (struct dvb_usb_device *dvbdev, +enum cxusb_open_type open_type) +{ +struct cxusb_medion_dev *cxdev = dvbdev->priv; +int ret =0 ; + +mutex_lock (&cxdev->open_lock); + +if (WARN_ON ((cxdev->open_type ==CXUSB_OPEN_INIT || + cxdev->open_type ==CXUSB_OPEN_NONE ) && + cxdev->open_ctr !=0 )) { + ret = -EINVAL ; + goto ret_unlock; + } + +if (cxdev->open_type ==CXUSB_OPEN_INIT ) { + ret = -EAGAIN ; + goto ret_unlock; + } + +if (cxdev->open_ctr ==0 ) { +if (cxdev->open_type != open_type) { +deb_info ("will acquire and switch to %s\n" , + open_type ==CXUSB_OPEN_ANALOG ? +"analog" :"digital" ); + +if (open_type ==CXUSB_OPEN_ANALOG ) { + ret =_cxusb_power_ctrl (dvbdev,1 ); +if (ret !=0 ) +dev_warn (&dvbdev->udev->dev, +"powerup for analog switch failed (%d)\n" , + ret); + + ret =cxusb_medion_set_mode (dvbdev, false); +if (ret !=0 ) + goto ret_unlock; + + ret =cxusb_medion_analog_init (dvbdev); +if (ret !=0 ) + goto ret_unlock; + }else {/* digital */ + ret =_cxusb_power_ctrl (dvbdev,1 ); +if (ret !=0 ) +dev_warn (&dvbdev->udev->dev, +"powerup for digital switch failed (%d)\n" , + ret); + + ret =cxusb_medion_set_mode (dvbdev, true); +if (ret !=0 ) + goto ret_unlock; + } + + cxdev->open_type = open_type; + }else +deb_info ("reacquired idle %s\n" , + open_type ==CXUSB_OPEN_ANALOG ? +"analog" :"digital" ); + + cxdev->open_ctr =1 ; + }else if (cxdev->open_type == open_type) { + cxdev->open_ctr++; +deb_info ("acquired %s\n" , open_type ==CXUSB_OPEN_ANALOG ? +"analog" :"digital" ); + }else + ret = -EBUSY ; + +ret_unlock: +mutex_unlock (&cxdev->open_lock); + +return ret; +} + +void cxusb_medion_put (struct dvb_usb_device *dvbdev) +{ +struct cxusb_medion_dev *cxdev = dvbdev->priv; + +mutex_lock (&cxdev->open_lock); + +if (cxdev->open_type ==CXUSB_OPEN_INIT ) { +WARN_ON (cxdev->open_ctr !=0 ); + cxdev->open_type =CXUSB_OPEN_NONE ; + goto unlock; + } + +if (!WARN_ON (cxdev->open_ctr <1 )) { + cxdev->open_ctr--; + +deb_info ("release %s\n" , cxdev->open_type == +CXUSB_OPEN_ANALOG ?"analog" :"digital" ); + } + +unlock: +mutex_unlock (&cxdev->open_lock); +} +/* DVB USB Driver stuff */ static struct dvb_usb_device_properties cxusb_medion_properties;static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties;
@@ -1326,12 +1600,101 @@ static struct dvb_usb_device_properties cxusb_d680_dmb_properties;static struct dvb_usb_device_properties cxusb_mygica_d689_properties;static struct dvb_usb_device_properties cxusb_mygica_t230_properties; +static int cxusb_medion_priv_init (struct dvb_usb_device *dvbdev) +{ +struct cxusb_medion_dev *cxdev = dvbdev->priv; + + cxdev->dvbdev = dvbdev; + cxdev->open_type =CXUSB_OPEN_INIT ; +mutex_init (&cxdev->open_lock); + +return 0 ; +} + +static void cxusb_medion_priv_destroy (struct dvb_usb_device *dvbdev) +{ +struct cxusb_medion_dev *cxdev = dvbdev->priv; + +mutex_destroy (&cxdev->open_lock); +} + +static bool cxusb_medion_check_altsetting (struct usb_host_interface *as) +{ +unsigned int ctr; + +for (ctr =0 ; ctr < as->desc.bNumEndpoints; ctr++) { +if ((as->endpoint[ctr].desc.bEndpointAddress & +USB_ENDPOINT_NUMBER_MASK ) !=2 ) +continue ; + +if (as->endpoint[ctr].desc.bEndpointAddress &USB_DIR_IN && + ((as->endpoint[ctr].desc.bmAttributes & +USB_ENDPOINT_XFERTYPE_MASK ) ==USB_ENDPOINT_XFER_ISOC )) +return true; + +break ; + } + +return false; +} + +static bool cxusb_medion_check_intf (struct usb_interface *intf) +{ +unsigned int ctr; + +if (intf->num_altsetting <2 ) { +dev_err (intf->usb_dev,"no alternate interface" ); + +return false; + } + +for (ctr =0 ; ctr < intf->num_altsetting; ctr++) { +if (intf->altsetting[ctr].desc.bAlternateSetting !=1 ) +continue ; + +if (cxusb_medion_check_altsetting (&intf->altsetting[ctr])) +return true; + +break ; + } + +dev_err (intf->usb_dev,"no iso interface" ); + +return false; +} +static int cxusb_probe (struct usb_interface *intf,const struct usb_device_id *id) { +struct dvb_usb_device *dvbdev; +int ret; + +/* Medion 95700 */ if (0 ==dvb_usb_device_init (intf, &cxusb_medion_properties, - THIS_MODULE, NULL, adapter_nr) || - 0 == dvb_usb_device_init(intf, &cxusb_bluebird_lgh064f_properties, +THIS_MODULE , &dvbdev, adapter_nr)) { +if (!cxusb_medion_check_intf (intf)) { + ret = -ENODEV ; + goto ret_uninit; + } + +_cxusb_power_ctrl (dvbdev,1 ); + ret =cxusb_medion_set_mode (dvbdev, false); +if (ret) + goto ret_uninit; + + ret =cxusb_medion_register_analog (dvbdev); + +cxusb_medion_set_mode (dvbdev, true); +_cxusb_power_ctrl (dvbdev,0 ); + +if (ret !=0 ) + goto ret_uninit; + +/* release device from INIT mode to normal operation */ +cxusb_medion_put (dvbdev); + +return 0 ; + } else if (0 == dvb_usb_device_init(intf, &cxusb_bluebird_lgh064f_properties, THIS_MODULE, NULL, adapter_nr) || 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dee1601_properties, THIS_MODULE, NULL, adapter_nr) ||
@@ -1361,6 +1724,11 @@ static int cxusb_probe(struct usb_interface *intf,return 0 ;return -EINVAL ; + +ret_uninit: +dvb_usb_device_exit (intf); + +return ret; }static void cxusb_disconnect (struct usb_interface *intf)
@@ -1369,6 +1737,9 @@ static void cxusb_disconnect(struct usb_interface *intf)struct cxusb_state *st = d->priv;struct i2c_client *client; +if (d->props.devices[0 ].warm_ids[0 ] == &cxusb_table[MEDION_MD95700 ]) +cxusb_medion_unregister_analog (d); +/* remove I2C client for tuner */ client = st->i2c_client_tuner;if (client) {
@@ -1386,31 +1757,6 @@ static void cxusb_disconnect(struct usb_interface *intf)dvb_usb_device_exit (intf); } -enum cxusb_table_index { -MEDION_MD95700 , -DVICO_BLUEBIRD_LG064F_COLD , -DVICO_BLUEBIRD_LG064F_WARM , -DVICO_BLUEBIRD_DUAL_1_COLD , -DVICO_BLUEBIRD_DUAL_1_WARM , -DVICO_BLUEBIRD_LGZ201_COLD , -DVICO_BLUEBIRD_LGZ201_WARM , -DVICO_BLUEBIRD_TH7579_COLD , -DVICO_BLUEBIRD_TH7579_WARM , -DIGITALNOW_BLUEBIRD_DUAL_1_COLD , -DIGITALNOW_BLUEBIRD_DUAL_1_WARM , -DVICO_BLUEBIRD_DUAL_2_COLD , -DVICO_BLUEBIRD_DUAL_2_WARM , -DVICO_BLUEBIRD_DUAL_4 , -DVICO_BLUEBIRD_DVB_T_NANO_2 , -DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM , -AVERMEDIA_VOLAR_A868R , -DVICO_BLUEBIRD_DUAL_4_REV_2 , -CONEXANT_D680_DMB , -MYGICA_D689 , -MYGICA_T230 , - NR__cxusb_table_index -}; -static struct usb_device_id cxusb_table[NR__cxusb_table_index +1 ] = { [MEDION_MD95700 ] = {USB_DEVICE (USB_VID_MEDION ,USB_PID_MEDION_MD95700 )
@@ -1484,13 +1830,16 @@ static struct dvb_usb_device_properties cxusb_medion_properties = { .usb_ctrl = CYPRESS_FX2, - .size_of_priv = sizeof(struct cxusb_state), + .size_of_priv = sizeof(struct cxusb_medion_dev), + .priv_init = cxusb_medion_priv_init, + .priv_destroy = cxusb_medion_priv_destroy, .num_adapters = 1, .adapter = { { .num_frontends = 1, .fe = {{ + .caps = DVB_USB_ADAP_STREAMING_CTRL_NO_URB, .streaming_ctrl = cxusb_streaming_ctrl, .frontend_attach = cxusb_cx22702_frontend_attach, .tuner_attach = cxusb_fmd1216me_tuner_attach,
@@ -2197,6 +2546,7 @@ module_usb_driver(cxusb_driver);MODULE_AUTHOR ("Patrick Boettcher <[email protected]>" );MODULE_AUTHOR ("Michael Krufky <[email protected]>" );MODULE_AUTHOR ("Chris Pascoe <[email protected]>" ); +MODULE_AUTHOR ("Maciej S. Szmigiero <[email protected]>" );MODULE_DESCRIPTION ("Driver for Conexant USB2.0 hybrid reference design" );MODULE_VERSION ("1.0-alpha" );MODULE_LICENSE ("GPL" );
drivers/media/usb/dvb-usb/cxusb.h +48 -0
64 lines not on this page · raw message
drivers/media/usb/dvb-usb/dvb-usb-dvb.c +17 -3
@@ -15,6 +15,7 @@ static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff) {struct dvb_usb_adapter *adap = dvbdmxfeed->demux->priv;int newfeedcount, ret; +bool streaming_ctrl_no_urb;if (adap ==NULL )return -ENODEV ;
@@ -24,12 +25,16 @@ static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff)return -EINVAL ; } + streaming_ctrl_no_urb = adap->props.fe[adap->active_fe].caps & +DVB_USB_ADAP_STREAMING_CTRL_NO_URB ; newfeedcount = adap->feedcount + (onoff ?1 :-1 );/* stop feed before setting a new pid if there will be no pid anymore */ if (newfeedcount ==0 ) {deb_ts ("stop feeding\n" ); -usb_urb_kill (&adap->fe_adap[adap->active_fe].stream); + +if (streaming_ctrl_no_urb) +usb_urb_kill (&adap->fe_adap[adap->active_fe].stream);if (adap->props.fe[adap->active_fe].streaming_ctrl !=NULL ) { ret = adap->props.fe[adap->active_fe].streaming_ctrl (adap,0 );
@@ -38,6 +43,9 @@ static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff)return ret; } } + +if (!streaming_ctrl_no_urb) +usb_urb_kill (&adap->fe_adap[adap->active_fe].stream); } adap->feedcount = newfeedcount;
@@ -56,8 +64,10 @@ static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff)* for reception. */ if (adap->feedcount == onoff && adap->feedcount >0 ) { -deb_ts ("submitting all URBs\n" ); -usb_urb_submit (&adap->fe_adap[adap->active_fe].stream); +if (!streaming_ctrl_no_urb) { +deb_ts ("submitting all URBs early\n" ); +usb_urb_submit (&adap->fe_adap[adap->active_fe].stream); + }deb_ts ("controlling pid parser\n" ); if (adap->props.fe[adap->active_fe].caps & DVB_USB_ADAP_HAS_PID_FILTER &&
@@ -80,6 +90,10 @@ static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff) } } +if (streaming_ctrl_no_urb) { +deb_ts ("submitting all URBs late\n" ); +usb_urb_submit (&adap->fe_adap[adap->active_fe].stream); + } }return 0 ; }
drivers/media/usb/dvb-usb/dvb-usb-init.c +13 -0
@@ -133,6 +133,10 @@ static int dvb_usb_exit(struct dvb_usb_device *d)dvb_usb_i2c_exit (d);deb_info ("state should be zero now: %x\n" , d->state); d->state =DVB_USB_STATE_INIT ; + +if (d->priv !=NULL && d->props.priv_destroy !=NULL ) + d->props.priv_destroy (d); +kfree (d->priv);kfree (d);return 0 ;
@@ -154,6 +158,15 @@ static int dvb_usb_init(struct dvb_usb_device *d, short *adapter_nums)err ("no memory for priv in 'struct dvb_usb_device'" );return -ENOMEM ; } + +if (d->props.priv_init !=NULL ) { + ret = d->props.priv_init (d); +if (ret !=0 ) { +kfree (d->priv); + d->priv =NULL ; +return ret; + } + } }/* check the capabilities and set appropriate variables */
drivers/media/usb/dvb-usb/dvb-usb.h +8 -0
@@ -143,6 +143,7 @@ struct dvb_usb_adapter_fe_properties {#define DVB_USB_ADAP_NEED_PID_FILTERING 0x04#define DVB_USB_ADAP_RECEIVES_204_BYTE_TS 0x08#define DVB_USB_ADAP_RECEIVES_RAW_PAYLOAD 0x10 +#define DVB_USB_ADAP_STREAMING_CTRL_NO_URB 0x20int caps;int pid_filter_count;
@@ -234,6 +235,11 @@ enum dvb_usb_mode {* * @size_of_priv: how many bytes shall be allocated for the private field * of struct dvb_usb_device. +* @priv_init: optional callback to initialize the variable that private field +* of struct dvb_usb_device has pointer to just after it had been allocated and +* zeroed. +* @priv_destroy: just like priv_init, only called before deallocating +* the memory pointed by private field of struct dvb_usb_device. * * @power_ctrl: called to enable/disable power of the device. * @read_mac_address: called to read the MAC address of the device.
@@ -275,6 +281,8 @@ struct dvb_usb_device_properties {int no_reconnect;int size_of_priv; +int (*priv_init)(struct dvb_usb_device *); +void (*priv_destroy)(struct dvb_usb_device *);int num_adapters;struct dvb_usb_adapter_properties adapter[MAX_NO_OF_ADAPTER_PER_DEVICE ];
PATCH v6 6/6 cxusb: add analog mode support for Medion MD95700
In reply to a message not in the archiveThis patch adds support for analog part of Medion 95700 in the cxusb driver.
What works:
* Video capture at various sizes with sequential fields,
* Input switching (TV Tuner, Composite, S-Video),
* TV and radio tuning,
* Video standard switching and auto detection,
* Radio mode switching (stereo / mono),
* Unplugging while capturing,
* DVB / analog coexistence,
* Raw BT.656 stream support.
What does not work yet:
* Audio,
* VBI,
* Picture controls.
--- drivers/media/usb/dvb-usb/Kconfig | 16 +- drivers/media/usb/dvb-usb/Makefile | 3 + drivers/media/usb/dvb-usb/cxusb-analog.c | 1914 ++++++++++++++++++++++++++++++ drivers/media/usb/dvb-usb/cxusb.c | 2 - drivers/media/usb/dvb-usb/cxusb.h | 106 ++ 5 files changed, 2037 insertions(+), 4 deletions(-) create mode 100644 drivers/media/usb/dvb-usb/cxusb-analog.c
drivers/media/usb/dvb-usb/Kconfig +14 -2
@@ -138,12 +138,24 @@ config DVB_USB_CXUSB select MEDIA_TUNER_SI2157 if MEDIA_SUBDRV_AUTOSELECT help Say Y here to support the Conexant USB2.0 hybrid reference design. - Currently, only DVB and ATSC modes are supported, analog mode - shall be added in the future. Devices that require this module: + DVB and ATSC modes are supported, for a basic analog mode support + see the next option ("Analog support for the Conexant USB2.0 hybrid + reference design"). + Devices that require this module: Medion MD95700 hybrid USB2.0 device. DViCO FusionHDTV (Bluebird) USB2.0 devices +config DVB_USB_CXUSB_ANALOG + bool "Analog support for the Conexant USB2.0 hybrid reference design" + depends on DVB_USB_CXUSB && VIDEO_V4L2 + select VIDEO_CX25840 + select VIDEOBUF2_VMALLOC + help + Say Y here to enable basic analog mode support for the Conexant + USB2.0 hybrid reference design. + Currently this mode is supported only on a Medion MD95700 device. + config DVB_USB_M920X tristate "Uli m920x DVB-T USB2.0 support" depends on DVB_USB
drivers/media/usb/dvb-usb/Makefile +3 -0
@@ -42,6 +42,9 @@ dvb-usb-digitv-objs := digitv.o obj-$(CONFIG_DVB_USB_DIGITV) += dvb-usb-digitv.o dvb-usb-cxusb-objs := cxusb.o +ifeq ($(CONFIG_DVB_USB_CXUSB_ANALOG),y) +dvb-usb-cxusb-objs += cxusb-analog.o +endif obj-$(CONFIG_DVB_USB_CXUSB) += dvb-usb-cxusb.o dvb-usb-ttusb2-objs := ttusb2.o
drivers/media/usb/dvb-usb/cxusb-analog.c new file +1914 -0
1,914 lines not on this page · raw message
drivers/media/usb/dvb-usb/cxusb.c +0 -2
@@ -11,7 +11,6 @@* design, so it can be reused for the "analogue-only" device (if it will * appear at all). * -* TODO: Use the cx25840-driver for the analogue part * * Copyright (C) 2005 Patrick Boettcher ([email protected]) * Copyright (C) 2006 Michael Krufky ([email protected])
@@ -2548,5 +2547,4 @@ MODULE_AUTHOR("Michael Krufky <[email protected]>");MODULE_AUTHOR ("Chris Pascoe <[email protected]>" );MODULE_AUTHOR ("Maciej S. Szmigiero <[email protected]>" );MODULE_DESCRIPTION ("Driver for Conexant USB2.0 hybrid reference design" ); -MODULE_VERSION ("1.0-alpha" );MODULE_LICENSE ("GPL" );
drivers/media/usb/dvb-usb/cxusb.h +106 -0
154 lines not on this page · raw message