Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 25173
b: refs/heads/master
c: 0020d3e
h: refs/heads/master
i:
  25171: 22a789c
v: v3
  • Loading branch information
Hans Verkuil authored and Mauro Carvalho Chehab committed Apr 2, 2006
1 parent 5daeba0 commit 9d92070
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 140 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9bc7400a9d01b1fe05c7f0200e7384e17794f6e4
refs/heads/master: 0020d3ef915fc01a0184bc96eeb3c240bded5d8e
147 changes: 75 additions & 72 deletions trunk/drivers/media/video/bt8xx/bttv-driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -1023,14 +1023,12 @@ audio_input(struct bttv *btv, int input)
static void
i2c_vidiocschan(struct bttv *btv)
{
struct video_channel c;
v4l2_std_id std = bttv_tvnorms[btv->tvnorm].v4l2_id;

memset(&c,0,sizeof(c));
c.norm = btv->tvnorm;
c.channel = btv->input;
bttv_call_i2c_clients(btv,VIDIOCSCHAN,&c);
bttv_call_i2c_clients(btv, VIDIOC_S_INPUT, &btv->input);
bttv_call_i2c_clients(btv, VIDIOC_S_STD, &std);
if (btv->c.type == BTTV_BOARD_VOODOOTV_FM)
bttv_tda9880_setnorm(btv,c.norm);
bttv_tda9880_setnorm(btv,btv->tvnorm);
}

static int
Expand Down Expand Up @@ -1184,11 +1182,27 @@ static int get_control(struct bttv *btv, struct v4l2_control *c)
break;
if (i == BTTV_CTLS)
return -EINVAL;
if (i >= 4 && i <= 8) {
if (btv->audio_hook && i >= 4 && i <= 8) {
memset(&va,0,sizeof(va));
bttv_call_i2c_clients(btv, VIDIOCGAUDIO, &va);
if (btv->audio_hook)
btv->audio_hook(btv,&va,0);
btv->audio_hook(btv,&va,0);
switch (c->id) {
case V4L2_CID_AUDIO_MUTE:
c->value = (VIDEO_AUDIO_MUTE & va.flags) ? 1 : 0;
break;
case V4L2_CID_AUDIO_VOLUME:
c->value = va.volume;
break;
case V4L2_CID_AUDIO_BALANCE:
c->value = va.balance;
break;
case V4L2_CID_AUDIO_BASS:
c->value = va.bass;
break;
case V4L2_CID_AUDIO_TREBLE:
c->value = va.treble;
break;
}
return 0;
}
switch (c->id) {
case V4L2_CID_BRIGHTNESS:
Expand All @@ -1205,19 +1219,11 @@ static int get_control(struct bttv *btv, struct v4l2_control *c)
break;

case V4L2_CID_AUDIO_MUTE:
c->value = (VIDEO_AUDIO_MUTE & va.flags) ? 1 : 0;
break;
case V4L2_CID_AUDIO_VOLUME:
c->value = va.volume;
break;
case V4L2_CID_AUDIO_BALANCE:
c->value = va.balance;
break;
case V4L2_CID_AUDIO_BASS:
c->value = va.bass;
break;
case V4L2_CID_AUDIO_TREBLE:
c->value = va.treble;
bttv_call_i2c_clients(btv,VIDIOC_G_CTRL,c);
break;

case V4L2_CID_PRIVATE_CHROMA_AGC:
Expand Down Expand Up @@ -1269,11 +1275,35 @@ static int set_control(struct bttv *btv, struct v4l2_control *c)
break;
if (i == BTTV_CTLS)
return -EINVAL;
if (i >= 4 && i <= 8) {
if (btv->audio_hook && i >= 4 && i <= 8) {
memset(&va,0,sizeof(va));
bttv_call_i2c_clients(btv, VIDIOCGAUDIO, &va);
if (btv->audio_hook)
btv->audio_hook(btv,&va,0);
btv->audio_hook(btv,&va,0);
switch (c->id) {
case V4L2_CID_AUDIO_MUTE:
if (c->value) {
va.flags |= VIDEO_AUDIO_MUTE;
audio_mute(btv, 1);
} else {
va.flags &= ~VIDEO_AUDIO_MUTE;
audio_mute(btv, 0);
}
break;

case V4L2_CID_AUDIO_VOLUME:
va.volume = c->value;
break;
case V4L2_CID_AUDIO_BALANCE:
va.balance = c->value;
break;
case V4L2_CID_AUDIO_BASS:
va.bass = c->value;
break;
case V4L2_CID_AUDIO_TREBLE:
va.treble = c->value;
break;
}
btv->audio_hook(btv,&va,1);
return 0;
}
switch (c->id) {
case V4L2_CID_BRIGHTNESS:
Expand All @@ -1289,26 +1319,13 @@ static int set_control(struct bttv *btv, struct v4l2_control *c)
bt848_sat(btv,c->value);
break;
case V4L2_CID_AUDIO_MUTE:
if (c->value) {
va.flags |= VIDEO_AUDIO_MUTE;
audio_mute(btv, 1);
} else {
va.flags &= ~VIDEO_AUDIO_MUTE;
audio_mute(btv, 0);
}
break;

audio_mute(btv, c->value);
/* fall through */
case V4L2_CID_AUDIO_VOLUME:
va.volume = c->value;
break;
case V4L2_CID_AUDIO_BALANCE:
va.balance = c->value;
break;
case V4L2_CID_AUDIO_BASS:
va.bass = c->value;
break;
case V4L2_CID_AUDIO_TREBLE:
va.treble = c->value;
bttv_call_i2c_clients(btv,VIDIOC_S_CTRL,c);
break;

case V4L2_CID_PRIVATE_CHROMA_AGC:
Expand Down Expand Up @@ -1364,11 +1381,6 @@ static int set_control(struct bttv *btv, struct v4l2_control *c)
default:
return -EINVAL;
}
if (i >= 4 && i <= 8) {
bttv_call_i2c_clients(btv, VIDIOCSAUDIO, &va);
if (btv->audio_hook)
btv->audio_hook(btv,&va,1);
}
return 0;
}

Expand Down Expand Up @@ -1827,33 +1839,26 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg)
return -EINVAL;
mutex_lock(&btv->lock);
memset(t,0,sizeof(*t));
t->rxsubchans = V4L2_TUNER_SUB_MONO;
bttv_call_i2c_clients(btv, VIDIOC_G_TUNER, t);
strcpy(t->name, "Television");
t->type = V4L2_TUNER_ANALOG_TV;
t->capability = V4L2_TUNER_CAP_NORM;
t->rxsubchans = V4L2_TUNER_SUB_MONO;
t->type = V4L2_TUNER_ANALOG_TV;
if (btread(BT848_DSTATUS)&BT848_DSTATUS_HLOC)
t->signal = 0xffff;
{
struct video_tuner tuner;

memset(&tuner, 0, sizeof (tuner));
tuner.rangehigh = 0xffffffffUL;
bttv_call_i2c_clients(btv, VIDIOCGTUNER, &tuner);
t->rangelow = tuner.rangelow;
t->rangehigh = tuner.rangehigh;
}
{

if (btv->audio_hook) {
/* Hmmm ... */
struct video_audio va;
memset(&va, 0, sizeof(struct video_audio));
bttv_call_i2c_clients(btv, VIDIOCGAUDIO, &va);
if (btv->audio_hook)
btv->audio_hook(btv,&va,0);
btv->audio_hook(btv,&va,0);
t->audmode = V4L2_TUNER_MODE_MONO;
t->rxsubchans = V4L2_TUNER_SUB_MONO;
if(va.mode & VIDEO_SOUND_STEREO) {
t->audmode = V4L2_TUNER_MODE_STEREO;
t->rxsubchans |= V4L2_TUNER_SUB_STEREO;
t->audmode = V4L2_TUNER_MODE_STEREO;
t->rxsubchans = V4L2_TUNER_SUB_STEREO;
}
if(va.mode & VIDEO_SOUND_LANG1) {
if(va.mode & VIDEO_SOUND_LANG2) {
t->audmode = V4L2_TUNER_MODE_LANG1;
t->rxsubchans = V4L2_TUNER_SUB_LANG1
| V4L2_TUNER_SUB_LANG2;
Expand All @@ -1872,10 +1877,10 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg)
if (0 != t->index)
return -EINVAL;
mutex_lock(&btv->lock);
{
bttv_call_i2c_clients(btv, VIDIOC_S_TUNER, t);
if (btv->audio_hook) {
struct video_audio va;
memset(&va, 0, sizeof(struct video_audio));
bttv_call_i2c_clients(btv, VIDIOCGAUDIO, &va);
if (t->audmode == V4L2_TUNER_MODE_MONO)
va.mode = VIDEO_SOUND_MONO;
else if (t->audmode == V4L2_TUNER_MODE_STEREO ||
Expand All @@ -1885,9 +1890,7 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg)
va.mode = VIDEO_SOUND_LANG1;
else if (t->audmode == V4L2_TUNER_MODE_LANG2)
va.mode = VIDEO_SOUND_LANG2;
bttv_call_i2c_clients(btv, VIDIOCSAUDIO, &va);
if (btv->audio_hook)
btv->audio_hook(btv,&va,1);
btv->audio_hook(btv,&va,1);
}
mutex_unlock(&btv->lock);
return 0;
Expand All @@ -1912,15 +1915,17 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg)
return -EINVAL;
mutex_lock(&btv->lock);
btv->freq = f->frequency;
bttv_call_i2c_clients(btv,VIDIOCSFREQ,&btv->freq);
bttv_call_i2c_clients(btv,VIDIOC_S_FREQUENCY,f);
if (btv->has_matchbox && btv->radio_user)
tea5757_set_freq(btv,btv->freq);
mutex_unlock(&btv->lock);
return 0;
}
case VIDIOC_LOG_STATUS:
{
printk(KERN_INFO "bttv%d: ================= START STATUS CARD #%d =================\n", btv->c.nr, btv->c.nr);
bttv_call_i2c_clients(btv, VIDIOC_LOG_STATUS, NULL);
printk(KERN_INFO "bttv%d: ================== END STATUS CARD #%d ==================\n", btv->c.nr, btv->c.nr);
return 0;
}

Expand Down Expand Up @@ -2870,12 +2875,10 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
return 0;
}
*c = bttv_ctls[i];
if (i >= 4 && i <= 8) {
if (btv->audio_hook && i >= 4 && i <= 8) {
struct video_audio va;
memset(&va,0,sizeof(va));
bttv_call_i2c_clients(btv, VIDIOCGAUDIO, &va);
if (btv->audio_hook)
btv->audio_hook(btv,&va,0);
btv->audio_hook(btv,&va,0);
switch (bttv_ctls[i].id) {
case V4L2_CID_AUDIO_VOLUME:
if (!(va.flags & VIDEO_AUDIO_VOLUME))
Expand Down
54 changes: 21 additions & 33 deletions trunk/drivers/media/video/msp3400-driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,19 +283,6 @@ void msp_set_scart(struct i2c_client *client, int in, int out)
msp_write_dem(client, 0x40, state->i2s_mode);
}

void msp_set_mute(struct i2c_client *client)
{
struct msp_state *state = i2c_get_clientdata(client);

v4l_dbg(1, msp_debug, client, "mute audio\n");
msp_write_dsp(client, 0x0000, 0);
msp_write_dsp(client, 0x0007, 1);
if (state->has_scart2_out_volume)
msp_write_dsp(client, 0x0040, 1);
if (state->has_headphones)
msp_write_dsp(client, 0x0006, 0);
}

void msp_set_audio(struct i2c_client *client)
{
struct msp_state *state = i2c_get_clientdata(client);
Expand Down Expand Up @@ -347,7 +334,6 @@ static void msp_wake_thread(struct i2c_client *client)

if (NULL == state->kthread)
return;
msp_set_mute(client);
state->watch_stereo = 0;
state->restart = 1;
wake_up_interruptible(&state->wq);
Expand Down Expand Up @@ -375,19 +361,15 @@ int msp_sleep(struct msp_state *state, int timeout)

/* ------------------------------------------------------------------------ */

static int msp_mode_v4l2_to_v4l1(int rxsubchans)
static int msp_mode_v4l2_to_v4l1(int rxsubchans, int audmode)
{
int mode = 0;

if (rxsubchans & V4L2_TUNER_SUB_STEREO)
mode |= VIDEO_SOUND_STEREO;
if (rxsubchans & V4L2_TUNER_SUB_LANG2)
mode |= VIDEO_SOUND_LANG2 | VIDEO_SOUND_STEREO;
if (rxsubchans & V4L2_TUNER_SUB_LANG1)
mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_STEREO;
if (mode == 0)
mode |= VIDEO_SOUND_MONO;
return mode;
if (rxsubchans == V4L2_TUNER_SUB_MONO)
return VIDEO_SOUND_MONO;
if (rxsubchans == V4L2_TUNER_SUB_STEREO)
return VIDEO_SOUND_STEREO;
if (audmode == V4L2_TUNER_MODE_LANG2)
return VIDEO_SOUND_LANG2;
return VIDEO_SOUND_LANG1;
}

static int msp_mode_v4l1_to_v4l2(int mode)
Expand Down Expand Up @@ -606,7 +588,7 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
break;
if (state->opmode == OPMODE_AUTOSELECT)
msp_detect_stereo(client);
va->mode = msp_mode_v4l2_to_v4l1(state->rxsubchans);
va->mode = msp_mode_v4l2_to_v4l1(state->rxsubchans, state->audmode);
break;
}

Expand All @@ -621,7 +603,8 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
state->treble = va->treble;
msp_set_audio(client);

if (va->mode != 0 && state->radio == 0) {
if (va->mode != 0 && state->radio == 0 &&
state->audmode != msp_mode_v4l1_to_v4l2(va->mode)) {
state->audmode = msp_mode_v4l1_to_v4l2(va->mode);
msp_set_audmode(client);
}
Expand Down Expand Up @@ -727,6 +710,8 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)

if (state->radio) /* TODO: add mono/stereo support for radio */
break;
if (state->audmode == vt->audmode)
break;
state->audmode = vt->audmode;
/* only set audmode */
msp_set_audmode(client);
Expand Down Expand Up @@ -888,7 +873,7 @@ static int msp_attach(struct i2c_adapter *adapter, int address, int kind)

memset(state, 0, sizeof(*state));
state->v4l2_std = V4L2_STD_NTSC;
state->audmode = V4L2_TUNER_MODE_LANG1;
state->audmode = V4L2_TUNER_MODE_STEREO;
state->volume = 58880; /* 0db gain */
state->balance = 32768; /* 0db gain */
state->bass = 32768;
Expand Down Expand Up @@ -932,13 +917,16 @@ static int msp_attach(struct i2c_adapter *adapter, int address, int kind)
state->has_radio = msp_revision >= 'G';
/* Has headphones output: not for stripped down products */
state->has_headphones = msp_prod_lo < 5;
/* Has scart2 input: not in stripped down products of the '3' family */
state->has_scart2 = msp_family >= 4 || msp_prod_lo < 7;
/* Has scart3 input: not in stripped down products of the '3' family */
state->has_scart3 = msp_family >= 4 || msp_prod_lo < 5;
/* Has scart4 input: not in pre D revisions, not in stripped D revs */
state->has_scart4 = msp_family >= 4 || (msp_revision >= 'D' && msp_prod_lo < 5);
/* Has scart2 and scart3 inputs and scart2 output: not in stripped
down products of the '3' family */
state->has_scart23_in_scart2_out = msp_family >= 4 || msp_prod_lo < 5;
/* Has scart2 output: not in stripped down products of the '3' family */
state->has_scart2_out = msp_family >= 4 || msp_prod_lo < 5;
/* Has scart2 a volume control? Not in pre-D revisions. */
state->has_scart2_out_volume = msp_revision > 'C' && state->has_scart23_in_scart2_out;
state->has_scart2_out_volume = msp_revision > 'C' && state->has_scart2_out;
/* Has a configurable i2s out? */
state->has_i2s_conf = msp_revision >= 'G' && msp_prod_lo < 7;
/* Has subwoofer output: not in pre-D revs and not in stripped down products */
Expand Down
5 changes: 3 additions & 2 deletions trunk/drivers/media/video/msp3400-driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ struct msp_state {
u8 has_radio;
u8 has_headphones;
u8 has_ntsc_jp_d_k3;
u8 has_scart2;
u8 has_scart3;
u8 has_scart4;
u8 has_scart23_in_scart2_out;
u8 has_scart2_out;
u8 has_scart2_out_volume;
u8 has_i2s_conf;
u8 has_subwoofer;
Expand Down Expand Up @@ -98,7 +100,6 @@ 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_sleep(struct msp_state *state, int timeout);

Expand Down
Loading

0 comments on commit 9d92070

Please sign in to comment.