Example #1
0
static int vidioc_s_input(struct file *file, void *fh, unsigned int input)
{
	struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev;
	struct mxb *mxb = (struct mxb *)dev->ext_priv;
	int err = 0;
	int i = 0;

	DEB_EE(("VIDIOC_S_INPUT %d.\n", input));

	if (input >= MXB_INPUTS)
		return -EINVAL;

	mxb->cur_input = input;

	saa7146_set_hps_source_and_sync(dev, input_port_selection[input].hps_source,
			input_port_selection[input].hps_sync);

	/* prepare switching of tea6415c and saa7111a;
	   have a look at the 'background'-file for further informations  */
	switch (input) {
	case TUNER:
		i = SAA7115_COMPOSITE0;

		err = tea6415c_call(mxb, video, s_routing, 3, 17, 0);

		/* connect tuner-output always to multicable */
		if (!err)
			err = tea6415c_call(mxb, video, s_routing, 3, 13, 0);
		break;
	case AUX3_YC:
		/* nothing to be done here. aux3_yc is
		   directly connected to the saa711a */
		i = SAA7115_SVIDEO1;
		break;
	case AUX3:
		/* nothing to be done here. aux3 is
		   directly connected to the saa711a */
		i = SAA7115_COMPOSITE1;
		break;
	case AUX1:
		i = SAA7115_COMPOSITE0;
		err = tea6415c_call(mxb, video, s_routing, 1, 17, 0);
		break;
	}

	if (err)
		return err;

	/* switch video in saa7111a */
	if (saa7111a_call(mxb, video, s_routing, i, SAA7111_FMT_CCIR, 0))
		printk(KERN_ERR "VIDIOC_S_INPUT: could not address saa7111a.\n");

	/* switch the audio-source only if necessary */
	if (0 == mxb->cur_mute)
		tea6420_route_line(mxb, video_audio_connect[input]);

	return 0;
}
static int vidioc_s_input(struct file *file, void *fh, unsigned int input)
{
    struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev;
    struct mxb *mxb = (struct mxb *)dev->ext_priv;
    int err = 0;
    int i = 0;

    DEB_EE("VIDIOC_S_INPUT %d\n", input);

    if (input >= MXB_INPUTS)
        return -EINVAL;

    mxb->cur_input = input;

    saa7146_set_hps_source_and_sync(dev, input_port_selection[input].hps_source,
                                    input_port_selection[input].hps_sync);

    switch (input) {
    case TUNER:
        i = SAA7115_COMPOSITE0;

        err = tea6415c_call(mxb, video, s_routing, 3, 17, 0);


        if (!err)
            err = tea6415c_call(mxb, video, s_routing, 3, 13, 0);
        break;
    case AUX3_YC:
        i = SAA7115_SVIDEO1;
        break;
    case AUX3:
        i = SAA7115_COMPOSITE1;
        break;
    case AUX1:
        i = SAA7115_COMPOSITE0;
        err = tea6415c_call(mxb, video, s_routing, 1, 17, 0);
        break;
    }

    if (err)
        return err;


    if (saa7111a_call(mxb, video, s_routing, i, SAA7111_FMT_CCIR, 0))
        pr_err("VIDIOC_S_INPUT: could not address saa7111a\n");


    if (0 == mxb->cur_mute)
        tea6420_route_line(mxb, video_audio_connect[input]);

    return 0;
}
Example #3
0
static long vidioc_default(struct file *file, void *fh, bool valid_prio,
							int cmd, void *arg)
{
	struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev;
	struct mxb *mxb = (struct mxb *)dev->ext_priv;

	switch (cmd) {
	case MXB_S_AUDIO_CD:
	{
		int i = *(int *)arg;

		if (i < 0 || i >= MXB_AUDIOS) {
			DEB_D("invalid argument to MXB_S_AUDIO_CD: i:%d\n", i);
			return -EINVAL;
		}

		DEB_EE("MXB_S_AUDIO_CD: i:%d\n", i);

		tea6420_route_cd(mxb, i);
		return 0;
	}
	case MXB_S_AUDIO_LINE:
	{
		int i = *(int *)arg;

		if (i < 0 || i >= MXB_AUDIOS) {
			DEB_D("invalid argument to MXB_S_AUDIO_LINE: i:%d\n",
			      i);
			return -EINVAL;
		}

		DEB_EE("MXB_S_AUDIO_LINE: i:%d\n", i);
		tea6420_route_line(mxb, i);
		return 0;
	}
	default:
/*
		DEB2(pr_err("does not handle this ioctl\n"));
*/
		return -ENOIOCTLCMD;
	}
	return 0;
}
Example #4
0
static int vidioc_s_ctrl(struct file *file, void *fh, struct v4l2_control *vc)
{
	struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev;
	struct mxb *mxb = (struct mxb *)dev->ext_priv;
	int i = 0;

	for (i = MAXCONTROLS - 1; i >= 0; i--) {
		if (mxb_controls[i].id == vc->id)
			break;
	}

	if (i < 0)
		return dev->ext_vv_data->core_ops->vidioc_s_ctrl(file, fh, vc);

	if (vc->id == V4L2_CID_AUDIO_MUTE) {
		mxb->cur_mute = vc->value;
		/* switch the audio-source */
		tea6420_route_line(mxb, vc->value ? 6 :
				video_audio_connect[mxb->cur_input]);
		DEB_EE(("VIDIOC_S_CTRL, V4L2_CID_AUDIO_MUTE: %d.\n", vc->value));
	}
	return 0;
}
Example #5
0
/* bring hardware to a sane state. this has to be done, just in case someone
   wants to capture from this device before it has been properly initialized.
   the capture engine would badly fail, because no valid signal arrives on the
   saa7146, thus leading to timeouts and stuff. */
static int mxb_init_done(struct saa7146_dev* dev)
{
	struct mxb* mxb = (struct mxb*)dev->ext_priv;
	struct i2c_msg msg;
	struct tuner_setup tun_setup;
	v4l2_std_id std = V4L2_STD_PAL_BG;

	int i = 0, err = 0;

	/* select video mode in saa7111a */
	saa7111a_call(mxb, core, s_std, std);

	/* select tuner-output on saa7111a */
	i = 0;
	saa7111a_call(mxb, video, s_routing, SAA7115_COMPOSITE0,
		SAA7111_FMT_CCIR, 0);

	/* select a tuner type */
	tun_setup.mode_mask = T_ANALOG_TV;
	tun_setup.addr = ADDR_UNSET;
	tun_setup.type = TUNER_PHILIPS_PAL;
	tuner_call(mxb, tuner, s_type_addr, &tun_setup);
	/* tune in some frequency on tuner */
	mxb->cur_freq.tuner = 0;
	mxb->cur_freq.type = V4L2_TUNER_ANALOG_TV;
	mxb->cur_freq.frequency = freq;
	tuner_call(mxb, tuner, s_frequency, &mxb->cur_freq);

	/* set a default video standard */
	tuner_call(mxb, core, s_std, std);

	/* mute audio on tea6420s */
	tea6420_route_line(mxb, 6);
	tea6420_route_cd(mxb, 6);

	/* switch to tuner-channel on tea6415c */
	tea6415c_call(mxb, video, s_routing, 3, 17, 0);

	/* select tuner-output on multicable on tea6415c */
	tea6415c_call(mxb, video, s_routing, 3, 13, 0);

	/* the rest for mxb */
	mxb->cur_input = 0;
	mxb->cur_mute = 1;

	mxb->cur_mode = V4L2_TUNER_MODE_STEREO;

	/* check if the saa7740 (aka 'sound arena module') is present
	   on the mxb. if so, we must initialize it. due to lack of
	   informations about the saa7740, the values were reverse
	   engineered. */
	msg.addr = 0x1b;
	msg.flags = 0;
	msg.len = mxb_saa7740_init[0].length;
	msg.buf = &mxb_saa7740_init[0].data[0];

	err = i2c_transfer(&mxb->i2c_adapter, &msg, 1);
	if (err == 1) {
		/* the sound arena module is a pos, that's probably the reason
		   philips refuses to hand out a datasheet for the saa7740...
		   it seems to screw up the i2c bus, so we disable fast irq
		   based i2c transactions here and rely on the slow and safe
		   polling method ... */
		extension.flags &= ~SAA7146_USE_I2C_IRQ;
		for (i = 1; ; i++) {
			if (-1 == mxb_saa7740_init[i].length)
				break;

			msg.len = mxb_saa7740_init[i].length;
			msg.buf = &mxb_saa7740_init[i].data[0];
			err = i2c_transfer(&mxb->i2c_adapter, &msg, 1);
			if (err != 1) {
				DEB_D(("failed to initialize 'sound arena module'.\n"));
				goto err;
			}
		}
		INFO(("'sound arena module' detected.\n"));
	}
err:
	/* the rest for saa7146: you should definitely set some basic values
	   for the input-port handling of the saa7146. */

	/* ext->saa has been filled by the core driver */

	/* some stuff is done via variables */
	saa7146_set_hps_source_and_sync(dev, input_port_selection[mxb->cur_input].hps_source,
			input_port_selection[mxb->cur_input].hps_sync);

	/* some stuff is done via direct write to the registers */

	/* this is ugly, but because of the fact that this is completely
	   hardware dependend, it should be done directly... */
	saa7146_write(dev, DD1_STREAM_B,	0x00000000);
	saa7146_write(dev, DD1_INIT,		0x02000200);
	saa7146_write(dev, MC2, (MASK_09 | MASK_25 | MASK_10 | MASK_26));

	return 0;
}
static int mxb_init_done(struct saa7146_dev* dev)
{
    struct mxb* mxb = (struct mxb*)dev->ext_priv;
    struct i2c_msg msg;
    struct tuner_setup tun_setup;
    v4l2_std_id std = V4L2_STD_PAL_BG;

    int i = 0, err = 0;


    saa7111a_call(mxb, core, s_std, std);


    i = 0;
    saa7111a_call(mxb, video, s_routing, SAA7115_COMPOSITE0,
                  SAA7111_FMT_CCIR, 0);


    tun_setup.mode_mask = T_ANALOG_TV;
    tun_setup.addr = ADDR_UNSET;
    tun_setup.type = TUNER_PHILIPS_PAL;
    tuner_call(mxb, tuner, s_type_addr, &tun_setup);

    mxb->cur_freq.tuner = 0;
    mxb->cur_freq.type = V4L2_TUNER_ANALOG_TV;
    mxb->cur_freq.frequency = freq;
    tuner_call(mxb, tuner, s_frequency, &mxb->cur_freq);


    tuner_call(mxb, core, s_std, std);


    tea6420_route_line(mxb, 6);
    tea6420_route_cd(mxb, 6);


    tea6415c_call(mxb, video, s_routing, 3, 17, 0);


    tea6415c_call(mxb, video, s_routing, 3, 13, 0);


    mxb->cur_input = 0;
    mxb->cur_mute = 1;

    mxb->cur_mode = V4L2_TUNER_MODE_STEREO;

    msg.addr = 0x1b;
    msg.flags = 0;
    msg.len = mxb_saa7740_init[0].length;
    msg.buf = &mxb_saa7740_init[0].data[0];

    err = i2c_transfer(&mxb->i2c_adapter, &msg, 1);
    if (err == 1) {
        extension.flags &= ~SAA7146_USE_I2C_IRQ;
        for (i = 1; ; i++) {
            if (-1 == mxb_saa7740_init[i].length)
                break;

            msg.len = mxb_saa7740_init[i].length;
            msg.buf = &mxb_saa7740_init[i].data[0];
            err = i2c_transfer(&mxb->i2c_adapter, &msg, 1);
            if (err != 1) {
                DEB_D("failed to initialize 'sound arena module'\n");
                goto err;
            }
        }
        pr_info("'sound arena module' detected\n");
    }
err:




    saa7146_set_hps_source_and_sync(dev, input_port_selection[mxb->cur_input].hps_source,
                                    input_port_selection[mxb->cur_input].hps_sync);



    saa7146_write(dev, DD1_STREAM_B,	0x00000000);
    saa7146_write(dev, DD1_INIT,		0x02000200);
    saa7146_write(dev, MC2, (MASK_09 | MASK_25 | MASK_10 | MASK_26));

    return 0;
}