aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Ringel <stefan.ringel@arcor.de>2011-05-09 15:53:52 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-05-20 19:01:39 -0400
commitb8f7bd8769f61705fd9acc1bc64539d74dfd0265 (patch)
tree97df649bf25b8298b1a2a798d842b0ef8ed798c4
parentfb7ef9831a432a6ae82587d1477103c18f99be73 (diff)
[media] tm6000: vitual input enums
vitual input enums Signed-off-by: Stefan Ringel <stefan.ringel@arcor.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/staging/tm6000/tm6000-video.c100
1 files changed, 57 insertions, 43 deletions
diff --git a/drivers/staging/tm6000/tm6000-video.c b/drivers/staging/tm6000/tm6000-video.c
index e1a7eb238727..8b3bf7e3e39f 100644
--- a/drivers/staging/tm6000/tm6000-video.c
+++ b/drivers/staging/tm6000/tm6000-video.c
@@ -1083,35 +1083,37 @@ static int vidioc_s_std (struct file *file, void *priv, v4l2_std_id *norm)
1083 return 0; 1083 return 0;
1084} 1084}
1085 1085
1086static const char *iname [] = {
1087 [TM6000_INPUT_TV] = "Television",
1088 [TM6000_INPUT_COMPOSITE1] = "Composite 1",
1089 [TM6000_INPUT_COMPOSITE2] = "Composite 2",
1090 [TM6000_INPUT_SVIDEO] = "S-Video",
1091};
1092
1086static int vidioc_enum_input(struct file *file, void *priv, 1093static int vidioc_enum_input(struct file *file, void *priv,
1087 struct v4l2_input *inp) 1094 struct v4l2_input *i)
1088{ 1095{
1089 struct tm6000_fh *fh = priv; 1096 struct tm6000_fh *fh = priv;
1090 struct tm6000_core *dev = fh->dev; 1097 struct tm6000_core *dev = fh->dev;
1098 unsigned int n;
1091 1099
1092 switch (inp->index) { 1100 n = i->index;
1093 case TM6000_INPUT_TV: 1101 if (n >= 3)
1094 inp->type = V4L2_INPUT_TYPE_TUNER;
1095 strcpy(inp->name, "Television");
1096 break;
1097 case TM6000_INPUT_COMPOSITE:
1098 if (dev->caps.has_input_comp) {
1099 inp->type = V4L2_INPUT_TYPE_CAMERA;
1100 strcpy(inp->name, "Composite");
1101 } else
1102 return -EINVAL;
1103 break;
1104 case TM6000_INPUT_SVIDEO:
1105 if (dev->caps.has_input_svid) {
1106 inp->type = V4L2_INPUT_TYPE_CAMERA;
1107 strcpy(inp->name, "S-Video");
1108 } else
1109 return -EINVAL;
1110 break;
1111 default:
1112 return -EINVAL; 1102 return -EINVAL;
1113 } 1103
1114 inp->std = TM6000_STD; 1104 if (!dev->vinput[n].type)
1105 return -EINVAL;
1106
1107 i->index = n;
1108
1109 if (dev->vinput[n].type == TM6000_INPUT_TV)
1110 i->type = V4L2_INPUT_TYPE_TUNER;
1111 else
1112 i->type = V4L2_INPUT_TYPE_CAMERA;
1113
1114 strcpy(i->name, iname[dev->vinput[n].type]);
1115
1116 i->std = TM6000_STD;
1115 1117
1116 return 0; 1118 return 0;
1117} 1119}
@@ -1125,33 +1127,21 @@ static int vidioc_g_input(struct file *file, void *priv, unsigned int *i)
1125 1127
1126 return 0; 1128 return 0;
1127} 1129}
1130
1128static int vidioc_s_input(struct file *file, void *priv, unsigned int i) 1131static int vidioc_s_input(struct file *file, void *priv, unsigned int i)
1129{ 1132{
1130 struct tm6000_fh *fh = priv; 1133 struct tm6000_fh *fh = priv;
1131 struct tm6000_core *dev = fh->dev; 1134 struct tm6000_core *dev = fh->dev;
1132 int rc = 0; 1135 int rc = 0;
1133 char buf[1];
1134 1136
1135 switch (i) { 1137 if (i >= 3)
1136 case TM6000_INPUT_TV: 1138 return -EINVAL;
1137 dev->input = i; 1139 if (!dev->vinput[i].type)
1138 *buf = 0;
1139 break;
1140 case TM6000_INPUT_COMPOSITE:
1141 case TM6000_INPUT_SVIDEO:
1142 dev->input = i;
1143 *buf = 1;
1144 break;
1145 default:
1146 return -EINVAL; 1140 return -EINVAL;
1147 }
1148 rc = tm6000_read_write_usb(dev, USB_DIR_OUT | USB_TYPE_VENDOR,
1149 REQ_03_SET_GET_MCU_PIN, 0x03, 1, buf, 1);
1150 1141
1151 if (!rc) { 1142 dev->input = i;
1152 dev->input = i; 1143
1153 rc = vidioc_s_std(file, priv, &dev->vfd->current_norm); 1144 rc = vidioc_s_std(file, priv, &dev->vfd->current_norm);
1154 }
1155 1145
1156 return rc; 1146 return rc;
1157} 1147}
@@ -1379,9 +1369,15 @@ static int radio_s_tuner(struct file *file, void *priv,
1379static int radio_enum_input(struct file *file, void *priv, 1369static int radio_enum_input(struct file *file, void *priv,
1380 struct v4l2_input *i) 1370 struct v4l2_input *i)
1381{ 1371{
1372 struct tm6000_fh *fh = priv;
1373 struct tm6000_core *dev = fh->dev;
1374
1382 if (i->index != 0) 1375 if (i->index != 0)
1383 return -EINVAL; 1376 return -EINVAL;
1384 1377
1378 if (!dev->rinput.type)
1379 return -EINVAL;
1380
1385 strcpy(i->name, "Radio"); 1381 strcpy(i->name, "Radio");
1386 i->type = V4L2_INPUT_TYPE_TUNER; 1382 i->type = V4L2_INPUT_TYPE_TUNER;
1387 1383
@@ -1390,7 +1386,14 @@ static int radio_enum_input(struct file *file, void *priv,
1390 1386
1391static int radio_g_input(struct file *filp, void *priv, unsigned int *i) 1387static int radio_g_input(struct file *filp, void *priv, unsigned int *i)
1392{ 1388{
1393 *i = 0; 1389 struct tm6000_fh *fh = priv;
1390 struct tm6000_core *dev = fh->dev;
1391
1392 if (dev->input !=5)
1393 return -EINVAL;
1394
1395 *i = dev->input -5;
1396
1394 return 0; 1397 return 0;
1395} 1398}
1396 1399
@@ -1410,6 +1413,17 @@ static int radio_s_audio(struct file *file, void *priv,
1410 1413
1411static int radio_s_input(struct file *filp, void *priv, unsigned int i) 1414static int radio_s_input(struct file *filp, void *priv, unsigned int i)
1412{ 1415{
1416 struct tm6000_fh *fh = priv;
1417 struct tm6000_core *dev = fh->dev;
1418
1419 if (i)
1420 return -EINVAL;
1421
1422 if (!dev->rinput.type)
1423 return -EINVAL;
1424
1425 dev->input = i + 5;
1426
1413 return 0; 1427 return 0;
1414} 1428}
1415 1429