aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2013-01-29 05:21:02 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-02-05 15:23:47 -0500
commited986d1fee77bbbb62291a1db1c7edbb00d99515 (patch)
tree6c70d0663a9a794e11b28301749faf5dac3c756d
parentcd13823f5db3e66552801c04f0e761408ef17eb0 (diff)
[media] meye: convert to the control framework
Convert the meye driver to the control framework. Some private controls have been replaced with standardized controls (SHARPNESS and JPEGQUAL). The AGC control looks like it can be replaced by the AUTOGAIN control, but it isn't a boolean so I do not know how to interpret it. The FRAMERATE control looks like it can be replaced by S_PARM, but again, without knowing how to interpret it I decided to leave it alone. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/pci/meye/meye.c278
-rw-r--r--drivers/media/pci/meye/meye.h2
-rw-r--r--include/uapi/linux/meye.h8
-rw-r--r--include/uapi/linux/v4l2-controls.h5
4 files changed, 99 insertions, 194 deletions
diff --git a/drivers/media/pci/meye/meye.c b/drivers/media/pci/meye/meye.c
index 3b39deaa8f6b..7859c43479d7 100644
--- a/drivers/media/pci/meye/meye.c
+++ b/drivers/media/pci/meye/meye.c
@@ -35,6 +35,8 @@
35#include <media/v4l2-common.h> 35#include <media/v4l2-common.h>
36#include <media/v4l2-device.h> 36#include <media/v4l2-device.h>
37#include <media/v4l2-ioctl.h> 37#include <media/v4l2-ioctl.h>
38#include <media/v4l2-fh.h>
39#include <media/v4l2-event.h>
38#include <asm/uaccess.h> 40#include <asm/uaccess.h>
39#include <asm/io.h> 41#include <asm/io.h>
40#include <linux/delay.h> 42#include <linux/delay.h>
@@ -865,7 +867,7 @@ static int meye_open(struct file *file)
865 meye.grab_buffer[i].state = MEYE_BUF_UNUSED; 867 meye.grab_buffer[i].state = MEYE_BUF_UNUSED;
866 kfifo_reset(&meye.grabq); 868 kfifo_reset(&meye.grabq);
867 kfifo_reset(&meye.doneq); 869 kfifo_reset(&meye.doneq);
868 return 0; 870 return v4l2_fh_open(file);
869} 871}
870 872
871static int meye_release(struct file *file) 873static int meye_release(struct file *file)
@@ -873,7 +875,7 @@ static int meye_release(struct file *file)
873 mchip_hic_stop(); 875 mchip_hic_stop();
874 mchip_dma_free(); 876 mchip_dma_free();
875 clear_bit(0, &meye.in_use); 877 clear_bit(0, &meye.in_use);
876 return 0; 878 return v4l2_fh_release(file);
877} 879}
878 880
879static int meyeioc_g_params(struct meye_params *p) 881static int meyeioc_g_params(struct meye_params *p)
@@ -1032,8 +1034,9 @@ static int vidioc_querycap(struct file *file, void *fh,
1032 cap->version = (MEYE_DRIVER_MAJORVERSION << 8) + 1034 cap->version = (MEYE_DRIVER_MAJORVERSION << 8) +
1033 MEYE_DRIVER_MINORVERSION; 1035 MEYE_DRIVER_MINORVERSION;
1034 1036
1035 cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | 1037 cap->device_caps = V4L2_CAP_VIDEO_CAPTURE |
1036 V4L2_CAP_STREAMING; 1038 V4L2_CAP_STREAMING;
1039 cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
1037 1040
1038 return 0; 1041 return 0;
1039} 1042}
@@ -1063,191 +1066,50 @@ static int vidioc_s_input(struct file *file, void *fh, unsigned int i)
1063 return 0; 1066 return 0;
1064} 1067}
1065 1068
1066static int vidioc_queryctrl(struct file *file, void *fh, 1069static int meye_s_ctrl(struct v4l2_ctrl *ctrl)
1067 struct v4l2_queryctrl *c)
1068{
1069 switch (c->id) {
1070
1071 case V4L2_CID_BRIGHTNESS:
1072 c->type = V4L2_CTRL_TYPE_INTEGER;
1073 strcpy(c->name, "Brightness");
1074 c->minimum = 0;
1075 c->maximum = 63;
1076 c->step = 1;
1077 c->default_value = 32;
1078 c->flags = 0;
1079 break;
1080 case V4L2_CID_HUE:
1081 c->type = V4L2_CTRL_TYPE_INTEGER;
1082 strcpy(c->name, "Hue");
1083 c->minimum = 0;
1084 c->maximum = 63;
1085 c->step = 1;
1086 c->default_value = 32;
1087 c->flags = 0;
1088 break;
1089 case V4L2_CID_CONTRAST:
1090 c->type = V4L2_CTRL_TYPE_INTEGER;
1091 strcpy(c->name, "Contrast");
1092 c->minimum = 0;
1093 c->maximum = 63;
1094 c->step = 1;
1095 c->default_value = 32;
1096 c->flags = 0;
1097 break;
1098 case V4L2_CID_SATURATION:
1099 c->type = V4L2_CTRL_TYPE_INTEGER;
1100 strcpy(c->name, "Saturation");
1101 c->minimum = 0;
1102 c->maximum = 63;
1103 c->step = 1;
1104 c->default_value = 32;
1105 c->flags = 0;
1106 break;
1107 case V4L2_CID_AGC:
1108 c->type = V4L2_CTRL_TYPE_INTEGER;
1109 strcpy(c->name, "Agc");
1110 c->minimum = 0;
1111 c->maximum = 63;
1112 c->step = 1;
1113 c->default_value = 48;
1114 c->flags = 0;
1115 break;
1116 case V4L2_CID_MEYE_SHARPNESS:
1117 case V4L2_CID_SHARPNESS:
1118 c->type = V4L2_CTRL_TYPE_INTEGER;
1119 strcpy(c->name, "Sharpness");
1120 c->minimum = 0;
1121 c->maximum = 63;
1122 c->step = 1;
1123 c->default_value = 32;
1124
1125 /* Continue to report legacy private SHARPNESS ctrl but
1126 * say it is disabled in preference to ctrl in the spec
1127 */
1128 c->flags = (c->id == V4L2_CID_SHARPNESS) ? 0 :
1129 V4L2_CTRL_FLAG_DISABLED;
1130 break;
1131 case V4L2_CID_PICTURE:
1132 c->type = V4L2_CTRL_TYPE_INTEGER;
1133 strcpy(c->name, "Picture");
1134 c->minimum = 0;
1135 c->maximum = 63;
1136 c->step = 1;
1137 c->default_value = 0;
1138 c->flags = 0;
1139 break;
1140 case V4L2_CID_JPEGQUAL:
1141 c->type = V4L2_CTRL_TYPE_INTEGER;
1142 strcpy(c->name, "JPEG quality");
1143 c->minimum = 0;
1144 c->maximum = 10;
1145 c->step = 1;
1146 c->default_value = 8;
1147 c->flags = 0;
1148 break;
1149 case V4L2_CID_FRAMERATE:
1150 c->type = V4L2_CTRL_TYPE_INTEGER;
1151 strcpy(c->name, "Framerate");
1152 c->minimum = 0;
1153 c->maximum = 31;
1154 c->step = 1;
1155 c->default_value = 0;
1156 c->flags = 0;
1157 break;
1158 default:
1159 return -EINVAL;
1160 }
1161
1162 return 0;
1163}
1164
1165static int vidioc_s_ctrl(struct file *file, void *fh, struct v4l2_control *c)
1166{ 1070{
1167 mutex_lock(&meye.lock); 1071 mutex_lock(&meye.lock);
1168 switch (c->id) { 1072 switch (ctrl->id) {
1169 case V4L2_CID_BRIGHTNESS: 1073 case V4L2_CID_BRIGHTNESS:
1170 sony_pic_camera_command( 1074 sony_pic_camera_command(
1171 SONY_PIC_COMMAND_SETCAMERABRIGHTNESS, c->value); 1075 SONY_PIC_COMMAND_SETCAMERABRIGHTNESS, ctrl->val);
1172 meye.brightness = c->value << 10; 1076 meye.brightness = ctrl->val << 10;
1173 break; 1077 break;
1174 case V4L2_CID_HUE: 1078 case V4L2_CID_HUE:
1175 sony_pic_camera_command( 1079 sony_pic_camera_command(
1176 SONY_PIC_COMMAND_SETCAMERAHUE, c->value); 1080 SONY_PIC_COMMAND_SETCAMERAHUE, ctrl->val);
1177 meye.hue = c->value << 10; 1081 meye.hue = ctrl->val << 10;
1178 break; 1082 break;
1179 case V4L2_CID_CONTRAST: 1083 case V4L2_CID_CONTRAST:
1180 sony_pic_camera_command( 1084 sony_pic_camera_command(
1181 SONY_PIC_COMMAND_SETCAMERACONTRAST, c->value); 1085 SONY_PIC_COMMAND_SETCAMERACONTRAST, ctrl->val);
1182 meye.contrast = c->value << 10; 1086 meye.contrast = ctrl->val << 10;
1183 break;