Beispiel #1
0
static int std_callback(struct saa7146_dev *dev, struct saa7146_standard *standard)
{
	struct mxb *mxb = (struct mxb *)dev->ext_priv;

	if (V4L2_STD_PAL_I == standard->id) {
		v4l2_std_id std = V4L2_STD_PAL_I;

		DEB_D(("VIDIOC_S_STD: setting mxb for PAL_I.\n"));
		/* set the 7146 gpio register -- I don't know what this does exactly */
		saa7146_write(dev, GPIO_CTRL, 0x00404050);
		/* unset the 7111 gpio register -- I don't know what this does exactly */
		saa7111a_call(mxb, core, s_gpio, 0);
		tuner_call(mxb, core, s_std, std);
	} else {
		v4l2_std_id std = V4L2_STD_PAL_BG;

		DEB_D(("VIDIOC_S_STD: setting mxb for PAL/NTSC/SECAM.\n"));
		/* set the 7146 gpio register -- I don't know what this does exactly */
		saa7146_write(dev, GPIO_CTRL, 0x00404050);
		/* set the 7111 gpio register -- I don't know what this does exactly */
		saa7111a_call(mxb, core, s_gpio, 1);
		tuner_call(mxb, core, s_std, std);
	}
	return 0;
}
static int std_callback(struct saa7146_dev *dev, struct saa7146_standard *standard)
{
    struct mxb *mxb = (struct mxb *)dev->ext_priv;

    if (V4L2_STD_PAL_I == standard->id) {
        v4l2_std_id std = V4L2_STD_PAL_I;

        DEB_D("VIDIOC_S_STD: setting mxb for PAL_I\n");

        saa7146_write(dev, GPIO_CTRL, 0x00404050);

        saa7111a_call(mxb, core, s_gpio, 0);
        tuner_call(mxb, core, s_std, std);
    } else {
        v4l2_std_id std = V4L2_STD_PAL_BG;

        DEB_D("VIDIOC_S_STD: setting mxb for PAL/NTSC/SECAM\n");

        saa7146_write(dev, GPIO_CTRL, 0x00404050);

        saa7111a_call(mxb, core, s_gpio, 1);
        tuner_call(mxb, core, s_std, std);
    }
    return 0;
}
Beispiel #3
0
static void cx231xx_config_tuner(struct cx231xx *dev)
{
	struct tuner_setup tun_setup;
	struct v4l2_frequency f;

	if (dev->tuner_type == TUNER_ABSENT)
		return;

	tun_setup.mode_mask = T_ANALOG_TV | T_RADIO;
	tun_setup.type = dev->tuner_type;
	tun_setup.addr = dev->tuner_addr;
	tun_setup.tuner_callback = cx231xx_tuner_callback;

	tuner_call(dev, tuner, s_type_addr, &tun_setup);

#if 0
	if (tun_setup.type == TUNER_XC5000) {
		static struct xc2028_ctrl ctrl = {
			.fname = XC5000_DEFAULT_FIRMWARE,
			.max_len = 64,
			.demod = 0;
		};
		struct v4l2_priv_tun_config cfg = {
			.tuner = dev->tuner_type,
			.priv = &ctrl,
		};
		tuner_call(dev, tuner, s_config, &cfg);
	}
#endif
	/* configure tuner */
	f.tuner = 0;
	f.type = V4L2_TUNER_ANALOG_TV;
	f.frequency = 9076;	/* just a magic number */
	dev->ctl_freq = f.frequency;
	call_all(dev, tuner, s_frequency, &f);

}

void cx231xx_card_setup(struct cx231xx *dev)
{

	cx231xx_set_model(dev);

	dev->tuner_type = cx231xx_boards[dev->model].tuner_type;
	if (cx231xx_boards[dev->model].tuner_addr)
		dev->tuner_addr = cx231xx_boards[dev->model].tuner_addr;

	/* request some modules */
	if (dev->board.decoder == CX231XX_AVDECODER) {
		dev->sd_cx25840 = v4l2_i2c_new_subdev(&dev->v4l2_dev,
					&dev->i2c_bus[0].i2c_adap,
					"cx25840", 0x88 >> 1, NULL);
		if (dev->sd_cx25840 == NULL)
			cx231xx_info("cx25840 subdev registration failure\n");
		cx25840_call(dev, core, load_fw);

	}
Beispiel #4
0
static int vidioc_s_frequency(struct file *file, void *fh, struct v4l2_frequency *f)
{
	struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev;
	struct mxb *mxb = (struct mxb *)dev->ext_priv;
	struct saa7146_vv *vv = dev->vv_data;

	if (f->tuner)
		return -EINVAL;

	if (V4L2_TUNER_ANALOG_TV != f->type)
		return -EINVAL;

	if (mxb->cur_input) {
		DEB_D(("VIDIOC_S_FREQ: channel %d does not have a tuner!\n", mxb->cur_input));
		return -EINVAL;
	}

	mxb->cur_freq = *f;
	DEB_EE(("VIDIOC_S_FREQUENCY: freq:0x%08x.\n", mxb->cur_freq.frequency));

	/* tune in desired frequency */
	tuner_call(mxb, tuner, s_frequency, &mxb->cur_freq);

	/* hack: changing the frequency should invalidate the vbi-counter (=> alevt) */
	spin_lock(&dev->slock);
	vv->vbi_fieldcount = 0;
	spin_unlock(&dev->slock);

	return 0;
}
static int vidioc_s_frequency(struct file *file, void *fh, struct v4l2_frequency *f)
{
    struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev;
    struct mxb *mxb = (struct mxb *)dev->ext_priv;
    struct saa7146_vv *vv = dev->vv_data;

    if (f->tuner)
        return -EINVAL;

    if (V4L2_TUNER_ANALOG_TV != f->type)
        return -EINVAL;

    if (mxb->cur_input) {
        DEB_D("VIDIOC_S_FREQ: channel %d does not have a tuner!\n",
              mxb->cur_input);
        return -EINVAL;
    }

    mxb->cur_freq = *f;
    DEB_EE("VIDIOC_S_FREQUENCY: freq:0x%08x\n", mxb->cur_freq.frequency);


    tuner_call(mxb, tuner, s_frequency, &mxb->cur_freq);


    spin_lock(&dev->slock);
    vv->vbi_fieldcount = 0;
    spin_unlock(&dev->slock);

    return 0;
}
Beispiel #6
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;
}