[media] solo6x10: Simplify solo_enum_ext_input

Additionally, now it specifies which channels it's showing.

Signed-off-by: Ismael Luceno <ismael@iodev.co.uk>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
This commit is contained in:
Ismael Luceno 2016-05-04 13:21:21 -03:00 committed by Mauro Carvalho Chehab
parent 9c41e69086
commit f4bca74f37

View File

@ -386,26 +386,24 @@ static int solo_querycap(struct file *file, void *priv,
static int solo_enum_ext_input(struct solo_dev *solo_dev, static int solo_enum_ext_input(struct solo_dev *solo_dev,
struct v4l2_input *input) struct v4l2_input *input)
{ {
static const char * const dispnames_1[] = { "4UP" }; int ext = input->index - solo_dev->nr_chans;
static const char * const dispnames_2[] = { "4UP-1", "4UP-2" }; unsigned int nup, first;
static const char * const dispnames_5[] = {
"4UP-1", "4UP-2", "4UP-3", "4UP-4", "16UP"
};
const char * const *dispnames;
if (input->index >= (solo_dev->nr_chans + solo_dev->nr_ext)) if (ext >= solo_dev->nr_ext)
return -EINVAL; return -EINVAL;
if (solo_dev->nr_ext == 5) nup = (ext == 4) ? 16 : 4;
dispnames = dispnames_5; first = (ext & 3) << 2; /* first channel in the n-up */
else if (solo_dev->nr_ext == 2) snprintf(input->name, sizeof(input->name),
dispnames = dispnames_2; "Multi %d-up (cameras %d-%d)",
else nup, first + 1, first + nup);
dispnames = dispnames_1; /* Possible outputs:
* Multi 4-up (cameras 1-4)
snprintf(input->name, sizeof(input->name), "Multi %s", * Multi 4-up (cameras 5-8)
dispnames[input->index - solo_dev->nr_chans]); * Multi 4-up (cameras 9-12)
* Multi 4-up (cameras 13-16)
* Multi 16-up (cameras 1-16)
*/
return 0; return 0;
} }