Commit cfeb8839 authored by Hartmut Hackmann's avatar Hartmut Hackmann Committed by Mauro Carvalho Chehab
Browse files

V4L/DVB (5323): Updated support for tuner callbacks



This change supplies a more generic version of the tuner callback.
The tuner struct now has a function pointer
  int (*tuner_callback) (void *dev, int command, int arg)
additionally to a int config parameter.
both can be set through the TUNER_SET_TYPE_ADDR client call.
Note that the meaning of the parameters depend on the tuner type.

Signed-off-by: default avatarHartmut Hackmann <hartmut.hackmann@t-online.de>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent b8bc76d8
Loading
Loading
Loading
Loading
+3 −12
Original line number Diff line number Diff line
@@ -4185,6 +4185,9 @@ int saa7134_board_init2(struct saa7134_dev *dev)
{
	unsigned char buf;
	int board;
	struct tuner_setup tun_setup;
	tun_setup.config = 0;
	tun_setup.tuner_callback = saa7134_tuner_callback;

	switch (dev->board) {
	case SAA7134_BOARD_BMK_MPEX_NOTUNER:
@@ -4201,20 +4204,15 @@ int saa7134_board_init2(struct saa7134_dev *dev)
		dev->tuner_type = saa7134_boards[dev->board].tuner_type;

		if (TUNER_ABSENT != dev->tuner_type) {
				struct tuner_setup tun_setup;

				tun_setup.mode_mask = T_RADIO | T_ANALOG_TV | T_DIGITAL_TV;
				tun_setup.type = dev->tuner_type;
				tun_setup.addr = ADDR_UNSET;
				tun_setup.config = 0;
				tun_setup.gpio_func = NULL;

				saa7134_i2c_call_clients (dev, TUNER_SET_TYPE_ADDR, &tun_setup);
		}
		break;
	case SAA7134_BOARD_MD7134:
		{
		struct tuner_setup tun_setup;
		u8 subaddr;
		u8 data[3];
		int ret, tuner_t;
@@ -4275,8 +4273,6 @@ int saa7134_board_init2(struct saa7134_dev *dev)
		tun_setup.mode_mask = T_RADIO | T_ANALOG_TV | T_DIGITAL_TV;
		tun_setup.type = dev->tuner_type;
		tun_setup.addr = ADDR_UNSET;
		tun_setup.config = 0;
		tun_setup.gpio_func = NULL;

		saa7134_i2c_call_clients (dev, TUNER_SET_TYPE_ADDR,&tun_setup);
		}
@@ -4288,7 +4284,6 @@ int saa7134_board_init2(struct saa7134_dev *dev)
		 * the channel decoder. We have to make it transparent to find it
		 */
		{
		struct tuner_setup tun_setup;
		u8 data[] = { 0x07, 0x02};
		struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
		i2c_transfer(&dev->i2c_adap, &msg, 1);
@@ -4296,8 +4291,6 @@ int saa7134_board_init2(struct saa7134_dev *dev)
		tun_setup.mode_mask = T_ANALOG_TV | T_DIGITAL_TV;
		tun_setup.type = dev->tuner_type;
		tun_setup.addr = dev->tuner_addr;
		tun_setup.config = 0;
		tun_setup.gpio_func = NULL;

		saa7134_i2c_call_clients (dev, TUNER_SET_TYPE_ADDR,&tun_setup);
		}
@@ -4306,7 +4299,6 @@ int saa7134_board_init2(struct saa7134_dev *dev)
	case SAA7134_BOARD_PHILIPS_TIGER_S:
		{
		u8 data[] = { 0x3c, 0x33, 0x60};
		struct tuner_setup tun_setup;
		struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
		if(dev->autodetected && (dev->eedata[0x49] == 0x50)) {
			dev->board = SAA7134_BOARD_PHILIPS_TIGER_S;
@@ -4318,7 +4310,6 @@ int saa7134_board_init2(struct saa7134_dev *dev)
			tun_setup.type = TUNER_PHILIPS_TDA8290;
			tun_setup.addr = 0x4b;
			tun_setup.config = 2;
			tun_setup.gpio_func = (tuner_gpio_func_t) saa7134_set_gpio;

			saa7134_i2c_call_clients (dev, TUNER_SET_TYPE_ADDR,&tun_setup);
			data[2] = 0x68;
+23 −6
Original line number Diff line number Diff line
@@ -120,7 +120,6 @@ void saa7134_track_gpio(struct saa7134_dev *dev, char *msg)
void saa7134_set_gpio(struct saa7134_dev *dev, int bit_no, int value)
{
	u32 index, bitval;
	u8 sync_control;

	index = 1 << bit_no;
	switch (value) {
@@ -140,22 +139,40 @@ void saa7134_set_gpio(struct saa7134_dev *dev, int bit_no, int value)
		dprintk("setting GPIO%d to tristate\n", bit_no);
		saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, index, 0);
		break;
	case 4:	/* sync output on GPIO 22 for tda8275a, 50Hz*/
	case 5:	/* sync output on GPIO 22 for tda8275a, 60Hz*/
		if (bit_no == 22) {
			dprintk("setting GPIO22 to vsync %d\n", value - 4);
	}
}

int saa7134_tuner_callback(void *ptr, int command, int arg)
{
	u8 sync_control;
	struct saa7134_dev *dev = ptr;

	switch (dev->tuner_type) {
	case TUNER_PHILIPS_TDA8290:
		switch (command) {
		case 0: /* switch LNA gain through GPIO 22*/
			saa7134_set_gpio(dev, 22, arg) ;
			break;
		case 1: /* vsync output at GPIO22. 50 / 60Hz */
			dprintk("setting GPIO22 to vsync %d\n", arg);
			saa_andorb(SAA7134_VIDEO_PORT_CTRL3, 0x80, 0x80);
			saa_andorb(SAA7134_VIDEO_PORT_CTRL6, 0x0f, 0x03);
			if (value == 5)
			if (arg == 1)
				sync_control = 11;
			else
				sync_control = 17;
			saa_writeb(SAA7134_VGATE_START, sync_control);
			saa_writeb(SAA7134_VGATE_STOP, sync_control + 1);
			saa_andorb(SAA7134_MISC_VGATE_MSB, 0x03, 0x00);
			break;
		default:
			return -EINVAL;
		}
		break;
	default:
		return -ENODEV;
	}
	return 0;
}

/* ------------------------------------------------------------------ */
+1 −1
Original line number Diff line number Diff line
@@ -371,7 +371,7 @@ static int attach_inform(struct i2c_client *client)
		tun_setup.type = tuner;
		tun_setup.addr = saa7134_boards[dev->board].tuner_addr;
		tun_setup.config = saa7134_boards[dev->board].tuner_config;
		tun_setup.gpio_func = (tuner_gpio_func_t) saa7134_set_gpio;
		tun_setup.tuner_callback = saa7134_tuner_callback;

		if ((tun_setup.addr == ADDR_UNSET)||(tun_setup.addr == client->addr)) {

+1 −0
Original line number Diff line number Diff line
@@ -565,6 +565,7 @@ extern int saa7134_no_overlay;

void saa7134_track_gpio(struct saa7134_dev *dev, char *msg);
void saa7134_set_gpio(struct saa7134_dev *dev, int bit_no, int value);
int saa7134_tuner_callback(void *ptr, int command, int arg);

#define SAA7134_PGTABLE_SIZE 4096

+6 −6
Original line number Diff line number Diff line
@@ -211,19 +211,19 @@ static void tda827xa_lna_gain(struct i2c_client *c, int high)
	case 2:
		/* turn Vsync on */
		if (t->std & V4L2_STD_MN)
			arg = 5;
			arg = 1;
		else
			arg = 4;
		if (t->gpio_func)
			t->gpio_func(c->adapter->algo_data, 22, 5);
			arg = 0;
		if (t->tuner_callback)
			t->tuner_callback(c->adapter->algo_data, 1, arg);
		buf[1] = high ? 0 : 1;
		if (t->config == 2)
			buf[1] = high ? 1 : 0;
		i2c_transfer(c->adapter, &msg, 1);
		break;
	case 3: /* switch with GPIO of saa713x */
		if (t->gpio_func)
			t->gpio_func(c->adapter->algo_data, 22, high);
		if (t->tuner_callback)
			t->tuner_callback(c->adapter->algo_data, 0, high);
		break;
	}
}
Loading