Skip to content

Commit

Permalink
V4L/DVB (3249): Generalized cx25840 video/audio input handling
Browse files Browse the repository at this point in the history
- Added VIDIOC_S_AUDIO to set the audio inputs separately.
- Removed AUDC_SET_INPUT.
- Made the video inputs much more general.
- Removed cardtype CID and replaced with a CID to enable
the PVR150 workaround. The cardtype is no longer necessary
with the general video input change.
- Update VIDIOC_LOG_STATUS output to show the video and
audio inputs separately.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@brturbo.com.br>
  • Loading branch information
Hans Verkuil authored and Mauro Carvalho Chehab committed Jan 9, 2006
1 parent 3578d3d commit a8bbf12
Show file tree
Hide file tree
Showing 3 changed files with 153 additions and 141 deletions.
51 changes: 15 additions & 36 deletions drivers/media/video/cx25840/cx25840-audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ static int set_audclk_freq(struct i2c_client *client, u32 freq)
/* SA_MCLK_SEL=1, SA_MCLK_DIV=0x10 */
cx25840_write(client, 0x127, 0x50);

switch (state->audio_input) {
case AUDIO_TUNER:
if (state->aud_input != CX25840_AUDIO_SERIAL) {
switch (freq) {
case 32000:
/* VID_PLL and AUX_PLL */
Expand Down Expand Up @@ -79,12 +78,7 @@ static int set_audclk_freq(struct i2c_client *client, u32 freq)
cx25840_write4(client, 0x90c, 0xaa4f0108);
break;
}
break;

case AUDIO_EXTERN_1:
case AUDIO_EXTERN_2:
case AUDIO_INTERN:
case AUDIO_RADIO:
} else {
switch (freq) {
case 32000:
/* VID_PLL and AUX_PLL */
Expand Down Expand Up @@ -137,7 +131,6 @@ static int set_audclk_freq(struct i2c_client *client, u32 freq)
cx25840_write4(client, 0x90c, 0x55550108);
break;
}
break;
}

/* deassert soft reset */
Expand All @@ -148,48 +141,33 @@ static int set_audclk_freq(struct i2c_client *client, u32 freq)
return 0;
}

static int set_input(struct i2c_client *client, int audio_input)
void cx25840_audio_set_path(struct i2c_client *client)
{
struct cx25840_state *state = i2c_get_clientdata(client);

cx25840_dbg("set audio input (%d)\n", audio_input);

/* stop microcontroller */
cx25840_and_or(client, 0x803, ~0x10, 0);

/* Mute everything to prevent the PFFT! */
cx25840_write(client, 0x8d3, 0x1f);

switch (audio_input) {
case AUDIO_TUNER:
/* Set Path1 to Analog Demod Main Channel */
cx25840_write4(client, 0x8d0, 0x7038061f);

/* When the microcontroller detects the
* audio format, it will unmute the lines */
cx25840_and_or(client, 0x803, ~0x10, 0x10);
break;

case AUDIO_EXTERN_1:
case AUDIO_EXTERN_2:
case AUDIO_INTERN:
case AUDIO_RADIO:
if (state->aud_input == CX25840_AUDIO_SERIAL) {
/* Set Path1 to Serial Audio Input */
cx25840_write4(client, 0x8d0, 0x12100101);

/* The microcontroller should not be started for the
* non-tuner inputs: autodetection is specific for
* TV audio. */
break;
} else {
/* Set Path1 to Analog Demod Main Channel */
cx25840_write4(client, 0x8d0, 0x7038061f);

default:
cx25840_dbg("Invalid audio input selection %d\n", audio_input);
return -EINVAL;
/* When the microcontroller detects the
* audio format, it will unmute the lines */
cx25840_and_or(client, 0x803, ~0x10, 0x10);
}

state->audio_input = audio_input;

return set_audclk_freq(client, state->audclk_freq);
set_audclk_freq(client, state->audclk_freq);
}

inline static int get_volume(struct i2c_client *client)
Expand Down Expand Up @@ -292,7 +270,7 @@ inline static void set_mute(struct i2c_client *client, int mute)
{
struct cx25840_state *state = i2c_get_clientdata(client);

if (state->audio_input == AUDIO_TUNER) {
if (state->aud_input != CX25840_AUDIO_SERIAL) {
/* Must turn off microcontroller in order to mute sound.
* Not sure if this is the best method, but it does work.
* If the microcontroller is running, then it will undo any
Expand All @@ -316,10 +294,9 @@ int cx25840_audio(struct i2c_client *client, unsigned int cmd, void *arg)
struct v4l2_control *ctrl = arg;

switch (cmd) {
case AUDC_SET_INPUT:
return set_input(client, *(int *)arg);
case VIDIOC_INT_AUDIO_CLOCK_FREQ:
return set_audclk_freq(client, *(u32 *)arg);

case VIDIOC_G_CTRL:
switch (ctrl->id) {
case V4L2_CID_AUDIO_VOLUME:
Expand All @@ -341,6 +318,7 @@ int cx25840_audio(struct i2c_client *client, unsigned int cmd, void *arg)
return -EINVAL;
}
break;

case VIDIOC_S_CTRL:
switch (ctrl->id) {
case V4L2_CID_AUDIO_VOLUME:
Expand All @@ -362,6 +340,7 @@ int cx25840_audio(struct i2c_client *client, unsigned int cmd, void *arg)
return -EINVAL;
}
break;

default:
return -EINVAL;
}
Expand Down
Loading

0 comments on commit a8bbf12

Please sign in to comment.