Commit 8fc34867 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

[media] saa7134: use input types, instead of hardcoding strings

Currently, the saa7134 driver is hardcoding input names on each
board entry. More modern drivers define, instead, an enum for each
input type.

While the current logic works, it adds extra complexity at the driver,
as it needs to discover the type of the input using some euristics.

Instead, let's standardize the input types and use a type, instead of
a name on all places.

That will allow further patches to properly report the input type
via VIDIOC_G_INPUT and to remove an extra field from the struct to
identify if the input is for TV.

Please notice that several boards define an input for receiving composite
signals via a S-Video connector. The name of such input was inconsistent,
so this patch cleans it and make it to be properly reported the
same way for all boards.
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 2773b0e9
This diff is collapsed.
...@@ -112,7 +112,7 @@ int (*saa7134_dmasound_exit)(struct saa7134_dev *dev); ...@@ -112,7 +112,7 @@ int (*saa7134_dmasound_exit)(struct saa7134_dev *dev);
printk(KERN_DEBUG pr_fmt("irq: " fmt), ## arg); \ printk(KERN_DEBUG pr_fmt("irq: " fmt), ## arg); \
} while (0) } while (0)
void saa7134_track_gpio(struct saa7134_dev *dev, char *msg) void saa7134_track_gpio(struct saa7134_dev *dev, const char *msg)
{ {
unsigned long mode,status; unsigned long mode,status;
......
...@@ -192,7 +192,7 @@ static void mute_input_7134(struct saa7134_dev *dev) ...@@ -192,7 +192,7 @@ static void mute_input_7134(struct saa7134_dev *dev)
in = dev->input; in = dev->input;
mute = (dev->ctl_mute || mute = (dev->ctl_mute ||
(dev->automute && (&card(dev).radio) != in)); (dev->automute && (&card(dev).radio) != in));
if (card(dev).mute.name) { if (card(dev).mute.type) {
/* /*
* 7130 - we'll mute using some unconnected audio input * 7130 - we'll mute using some unconnected audio input
* 7134 - we'll probably should switch external mux with gpio * 7134 - we'll probably should switch external mux with gpio
...@@ -204,13 +204,14 @@ static void mute_input_7134(struct saa7134_dev *dev) ...@@ -204,13 +204,14 @@ static void mute_input_7134(struct saa7134_dev *dev)
if (dev->hw_mute == mute && if (dev->hw_mute == mute &&
dev->hw_input == in && !dev->insuspend) { dev->hw_input == in && !dev->insuspend) {
audio_dbg(1, "mute/input: nothing to do [mute=%d,input=%s]\n", audio_dbg(1, "mute/input: nothing to do [mute=%d,input=%s]\n",
mute, in->name); mute, saa7134_input_name[in->type]);
return; return;
} }
audio_dbg(1, "ctl_mute=%d automute=%d input=%s => mute=%d input=%s\n", audio_dbg(1, "ctl_mute=%d automute=%d input=%s => mute=%d input=%s\n",
dev->ctl_mute, dev->automute, dev->ctl_mute, dev->automute,
dev->input->name, mute, in->name); saa7134_input_name[dev->input->type], mute,
saa7134_input_name[in->type]);
dev->hw_mute = mute; dev->hw_mute = mute;
dev->hw_input = in; dev->hw_input = in;
...@@ -245,7 +246,7 @@ static void mute_input_7134(struct saa7134_dev *dev) ...@@ -245,7 +246,7 @@ static void mute_input_7134(struct saa7134_dev *dev)
mask = card(dev).gpiomask; mask = card(dev).gpiomask;
saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, mask, mask); saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, mask, mask);
saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, mask, in->gpio); saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, mask, in->gpio);
saa7134_track_gpio(dev,in->name); saa7134_track_gpio(dev, saa7134_input_name[in->type]);
} }
static void tvaudio_setmode(struct saa7134_dev *dev, static void tvaudio_setmode(struct saa7134_dev *dev,
...@@ -756,14 +757,14 @@ static int mute_input_7133(struct saa7134_dev *dev) ...@@ -756,14 +757,14 @@ static int mute_input_7133(struct saa7134_dev *dev)
if (0 != card(dev).gpiomask) { if (0 != card(dev).gpiomask) {
mask = card(dev).gpiomask; mask = card(dev).gpiomask;
if (card(dev).mute.name && dev->ctl_mute) if (card(dev).mute.type && dev->ctl_mute)
in = &card(dev).mute; in = &card(dev).mute;
else else
in = dev->input; in = dev->input;
saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, mask, mask); saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, mask, mask);
saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, mask, in->gpio); saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, mask, in->gpio);
saa7134_track_gpio(dev,in->name); saa7134_track_gpio(dev, saa7134_input_name[in->type]);
} }
return 0; return 0;
......
...@@ -409,7 +409,8 @@ static void set_tvnorm(struct saa7134_dev *dev, struct saa7134_tvnorm *norm) ...@@ -409,7 +409,8 @@ static void set_tvnorm(struct saa7134_dev *dev, struct saa7134_tvnorm *norm)
static void video_mux(struct saa7134_dev *dev, int input) static void video_mux(struct saa7134_dev *dev, int input)
{ {
video_dbg("video input = %d [%s]\n", input, card_in(dev, input).name); video_dbg("video input = %d [%s]\n",
input, saa7134_input_name[card_in(dev, input).type]);
dev->ctl_input = input; dev->ctl_input = input;
set_tvnorm(dev, dev->tvnorm); set_tvnorm(dev, dev->tvnorm);
saa7134_tvaudio_setinput(dev, &card_in(dev, input)); saa7134_tvaudio_setinput(dev, &card_in(dev, input));
...@@ -1381,11 +1382,11 @@ int saa7134_enum_input(struct file *file, void *priv, struct v4l2_input *i) ...@@ -1381,11 +1382,11 @@ int saa7134_enum_input(struct file *file, void *priv, struct v4l2_input *i)
n = i->index; n = i->index;
if (n >= SAA7134_INPUT_MAX) if (n >= SAA7134_INPUT_MAX)
return -EINVAL; return -EINVAL;
if (NULL == card_in(dev, i->index).name) if (card_in(dev, i->index).type == SAA7134_NO_INPUT)
return -EINVAL; return -EINVAL;
i->index = n; i->index = n;
i->type = V4L2_INPUT_TYPE_CAMERA; i->type = V4L2_INPUT_TYPE_CAMERA;
strcpy(i->name, card_in(dev, n).name); strcpy(i->name, saa7134_input_name[card_in(dev, n).type]);
if (card_in(dev, n).tv) if (card_in(dev, n).tv)
i->type = V4L2_INPUT_TYPE_TUNER; i->type = V4L2_INPUT_TYPE_TUNER;
if (n == dev->ctl_input) { if (n == dev->ctl_input) {
...@@ -1419,7 +1420,7 @@ int saa7134_s_input(struct file *file, void *priv, unsigned int i) ...@@ -1419,7 +1420,7 @@ int saa7134_s_input(struct file *file, void *priv, unsigned int i)
if (i >= SAA7134_INPUT_MAX) if (i >= SAA7134_INPUT_MAX)
return -EINVAL; return -EINVAL;
if (NULL == card_in(dev, i).name) if (card_in(dev, i).type == SAA7134_NO_INPUT)
return -EINVAL; return -EINVAL;
video_mux(dev, i); video_mux(dev, i);
return 0; return 0;
...@@ -1661,7 +1662,7 @@ int saa7134_g_tuner(struct file *file, void *priv, ...@@ -1661,7 +1662,7 @@ int saa7134_g_tuner(struct file *file, void *priv,
} }
if (n == SAA7134_INPUT_MAX) if (n == SAA7134_INPUT_MAX)
return -EINVAL; return -EINVAL;
if (NULL != card_in(dev, n).name) { if (card_in(dev, n).type != SAA7134_NO_INPUT) {
strcpy(t->name, "Television"); strcpy(t->name, "Television");
t->type = V4L2_TUNER_ANALOG_TV; t->type = V4L2_TUNER_ANALOG_TV;
saa_call_all(dev, tuner, g_tuner, t); saa_call_all(dev, tuner, g_tuner, t);
......
...@@ -361,12 +361,30 @@ struct saa7134_card_ir { ...@@ -361,12 +361,30 @@ struct saa7134_card_ir {
#define SET_CLOCK_INVERTED (1 << 2) #define SET_CLOCK_INVERTED (1 << 2)
#define SET_VSYNC_OFF (1 << 3) #define SET_VSYNC_OFF (1 << 3)
enum saa7134_input_types {
SAA7134_NO_INPUT = 0,
SAA7134_INPUT_MUTE,
SAA7134_INPUT_RADIO,
SAA7134_INPUT_TV,
SAA7134_INPUT_TV_MONO,
SAA7134_INPUT_COMPOSITE,
SAA7134_INPUT_COMPOSITE0,
SAA7134_INPUT_COMPOSITE1,
SAA7134_INPUT_COMPOSITE2,
SAA7134_INPUT_COMPOSITE3,
SAA7134_INPUT_COMPOSITE4,
SAA7134_INPUT_SVIDEO,
SAA7134_INPUT_SVIDEO0,
SAA7134_INPUT_SVIDEO1,
SAA7134_INPUT_COMPOSITE_OVER_SVIDEO,
};
struct saa7134_input { struct saa7134_input {
char *name; enum saa7134_input_types type;
unsigned int vmux; unsigned int vmux;
enum saa7134_audio_in amux; enum saa7134_audio_in amux;
unsigned int gpio; unsigned int gpio;
unsigned int tv:1; unsigned int tv:1;
}; };
enum saa7134_mpeg_type { enum saa7134_mpeg_type {
...@@ -410,7 +428,7 @@ struct saa7134_board { ...@@ -410,7 +428,7 @@ struct saa7134_board {
unsigned int ts_force_val:1; unsigned int ts_force_val:1;
}; };
#define card_has_radio(dev) (NULL != saa7134_boards[dev->board].radio.name) #define card_has_radio(dev) (SAA7134_NO_INPUT != saa7134_boards[dev->board].radio.type)
#define card_is_empress(dev) (SAA7134_MPEG_EMPRESS == saa7134_boards[dev->board].mpeg) #define card_is_empress(dev) (SAA7134_MPEG_EMPRESS == saa7134_boards[dev->board].mpeg)
#define card_is_dvb(dev) (SAA7134_MPEG_DVB == saa7134_boards[dev->board].mpeg) #define card_is_dvb(dev) (SAA7134_MPEG_DVB == saa7134_boards[dev->board].mpeg)
#define card_is_go7007(dev) (SAA7134_MPEG_GO7007 == saa7134_boards[dev->board].mpeg) #define card_is_go7007(dev) (SAA7134_MPEG_GO7007 == saa7134_boards[dev->board].mpeg)
...@@ -727,7 +745,7 @@ extern struct mutex saa7134_devlist_lock; ...@@ -727,7 +745,7 @@ extern struct mutex saa7134_devlist_lock;
extern int saa7134_no_overlay; extern int saa7134_no_overlay;
extern bool saa7134_userptr; extern bool saa7134_userptr;
void saa7134_track_gpio(struct saa7134_dev *dev, char *msg); void saa7134_track_gpio(struct saa7134_dev *dev, const char *msg);
void saa7134_set_gpio(struct saa7134_dev *dev, int bit_no, int value); void saa7134_set_gpio(struct saa7134_dev *dev, int bit_no, int value);
#define SAA7134_PGTABLE_SIZE 4096 #define SAA7134_PGTABLE_SIZE 4096
...@@ -760,6 +778,7 @@ extern int (*saa7134_dmasound_exit)(struct saa7134_dev *dev); ...@@ -760,6 +778,7 @@ extern int (*saa7134_dmasound_exit)(struct saa7134_dev *dev);
/* saa7134-cards.c */ /* saa7134-cards.c */
extern struct saa7134_board saa7134_boards[]; extern struct saa7134_board saa7134_boards[];
extern const char * const saa7134_input_name[];
extern const unsigned int saa7134_bcount; extern const unsigned int saa7134_bcount;
extern struct pci_device_id saa7134_pci_tbl[]; extern struct pci_device_id saa7134_pci_tbl[];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment