diff options
author | Prabhakar Lad <prabhakar.csengg@gmail.com> | 2014-10-12 16:40:38 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2014-10-28 14:09:40 -0400 |
commit | 41cf47b37c34fe47d39293e2114b914506311212 (patch) | |
tree | 7a2c0a7ae3638a93daeaa7549e301e61df6568a7 /drivers/media/platform/davinci | |
parent | 4bb1231a5f3262eec8d879386b88b4d48082fd46 (diff) |
[media] media: davinci: vpbe: use vb2_ioctl_* helpers
this patch adds support for using vb2_ioctl_* helpers.
Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/platform/davinci')
-rw-r--r-- | drivers/media/platform/davinci/vpbe_display.c | 178 |
1 files changed, 14 insertions, 164 deletions
diff --git a/drivers/media/platform/davinci/vpbe_display.c b/drivers/media/platform/davinci/vpbe_display.c index 970242caad4d..76450aa04de5 100644 --- a/drivers/media/platform/davinci/vpbe_display.c +++ b/drivers/media/platform/davinci/vpbe_display.c | |||
@@ -281,8 +281,11 @@ static void vpbe_buffer_queue(struct vb2_buffer *vb) | |||
281 | static int vpbe_start_streaming(struct vb2_queue *vq, unsigned int count) | 281 | static int vpbe_start_streaming(struct vb2_queue *vq, unsigned int count) |
282 | { | 282 | { |
283 | struct vpbe_layer *layer = vb2_get_drv_priv(vq); | 283 | struct vpbe_layer *layer = vb2_get_drv_priv(vq); |
284 | struct osd_state *osd_device = layer->disp_dev->osd_device; | ||
284 | int ret; | 285 | int ret; |
285 | 286 | ||
287 | osd_device->ops.disable_layer(osd_device, layer->layer_info.id); | ||
288 | |||
286 | /* Get the next frame from the buffer queue */ | 289 | /* Get the next frame from the buffer queue */ |
287 | layer->next_frm = layer->cur_frm = list_entry(layer->dma_queue.next, | 290 | layer->next_frm = layer->cur_frm = list_entry(layer->dma_queue.next, |
288 | struct vpbe_disp_buffer, list); | 291 | struct vpbe_disp_buffer, list); |
@@ -320,12 +323,15 @@ static int vpbe_start_streaming(struct vb2_queue *vq, unsigned int count) | |||
320 | static void vpbe_stop_streaming(struct vb2_queue *vq) | 323 | static void vpbe_stop_streaming(struct vb2_queue *vq) |
321 | { | 324 | { |
322 | struct vpbe_layer *layer = vb2_get_drv_priv(vq); | 325 | struct vpbe_layer *layer = vb2_get_drv_priv(vq); |
326 | struct osd_state *osd_device = layer->disp_dev->osd_device; | ||
323 | struct vpbe_display *disp = layer->disp_dev; | 327 | struct vpbe_display *disp = layer->disp_dev; |
324 | unsigned long flags; | 328 | unsigned long flags; |
325 | 329 | ||
326 | if (!vb2_is_streaming(vq)) | 330 | if (!vb2_is_streaming(vq)) |
327 | return; | 331 | return; |
328 | 332 | ||
333 | osd_device->ops.disable_layer(osd_device, layer->layer_info.id); | ||
334 | |||
329 | /* release all active buffers */ | 335 | /* release all active buffers */ |
330 | spin_lock_irqsave(&disp->dma_queue_lock, flags); | 336 | spin_lock_irqsave(&disp->dma_queue_lock, flags); |
331 | if (layer->cur_frm == layer->next_frm) { | 337 | if (layer->cur_frm == layer->next_frm) { |
@@ -1144,164 +1150,6 @@ vpbe_display_g_dv_timings(struct file *file, void *priv, | |||
1144 | return 0; | 1150 | return 0; |
1145 | } | 1151 | } |
1146 | 1152 | ||
1147 | static int vpbe_display_streamoff(struct file *file, void *priv, | ||
1148 | enum v4l2_buf_type buf_type) | ||
1149 | { | ||
1150 | struct vpbe_layer *layer = video_drvdata(file); | ||
1151 | struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev; | ||
1152 | struct osd_state *osd_device = layer->disp_dev->osd_device; | ||
1153 | int ret; | ||
1154 | |||
1155 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, | ||
1156 | "VIDIOC_STREAMOFF,layer id = %d\n", | ||
1157 | layer->device_id); | ||
1158 | |||
1159 | if (V4L2_BUF_TYPE_VIDEO_OUTPUT != buf_type) { | ||
1160 | v4l2_err(&vpbe_dev->v4l2_dev, "Invalid buffer type\n"); | ||
1161 | return -EINVAL; | ||
1162 | } | ||
1163 | |||
1164 | /* If streaming is not started, return error */ | ||
1165 | if (!layer->started) { | ||
1166 | v4l2_err(&vpbe_dev->v4l2_dev, "streaming not started in layer" | ||
1167 | " id = %d\n", layer->device_id); | ||
1168 | return -EINVAL; | ||
1169 | } | ||
1170 | |||
1171 | osd_device->ops.disable_layer(osd_device, | ||
1172 | layer->layer_info.id); | ||
1173 | layer->started = 0; | ||
1174 | ret = vb2_streamoff(&layer->buffer_queue, buf_type); | ||
1175 | |||
1176 | return ret; | ||
1177 | } | ||
1178 | |||
1179 | static int vpbe_display_streamon(struct file *file, void *priv, | ||
1180 | enum v4l2_buf_type buf_type) | ||
1181 | { | ||
1182 | struct vpbe_layer *layer = video_drvdata(file); | ||
1183 | struct vpbe_display *disp_dev = layer->disp_dev; | ||
1184 | struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev; | ||
1185 | struct osd_state *osd_device = disp_dev->osd_device; | ||
1186 | int ret; | ||
1187 | |||
1188 | osd_device->ops.disable_layer(osd_device, | ||
1189 | layer->layer_info.id); | ||
1190 | |||
1191 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "VIDIOC_STREAMON, layerid=%d\n", | ||
1192 | layer->device_id); | ||
1193 | |||
1194 | if (V4L2_BUF_TYPE_VIDEO_OUTPUT != buf_type) { | ||
1195 | v4l2_err(&vpbe_dev->v4l2_dev, "Invalid buffer type\n"); | ||
1196 | return -EINVAL; | ||
1197 | } | ||
1198 | |||
1199 | /* If Streaming is already started, return error */ | ||
1200 | if (layer->started) { | ||
1201 | v4l2_err(&vpbe_dev->v4l2_dev, "layer is already streaming\n"); | ||
1202 | return -EBUSY; | ||
1203 | } | ||
1204 | |||
1205 | /* | ||
1206 | * Call vb2_streamon to start streaming | ||
1207 | * in videobuf | ||
1208 | */ | ||
1209 | ret = vb2_streamon(&layer->buffer_queue, buf_type); | ||
1210 | if (ret) { | ||
1211 | v4l2_err(&vpbe_dev->v4l2_dev, | ||
1212 | "error in vb2_streamon\n"); | ||
1213 | return ret; | ||
1214 | } | ||
1215 | return ret; | ||
1216 | } | ||
1217 | |||
1218 | static int vpbe_display_dqbuf(struct file *file, void *priv, | ||
1219 | struct v4l2_buffer *buf) | ||
1220 | { | ||
1221 | struct vpbe_layer *layer = video_drvdata(file); | ||
1222 | struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev; | ||
1223 | int ret; | ||
1224 | |||
1225 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, | ||
1226 | "VIDIOC_DQBUF, layer id = %d\n", | ||
1227 | layer->device_id); | ||
1228 | |||
1229 | if (V4L2_BUF_TYPE_VIDEO_OUTPUT != buf->type) { | ||
1230 | v4l2_err(&vpbe_dev->v4l2_dev, "Invalid buffer type\n"); | ||
1231 | return -EINVAL; | ||
1232 | } | ||
1233 | if (file->f_flags & O_NONBLOCK) | ||
1234 | /* Call videobuf_dqbuf for non blocking mode */ | ||
1235 | ret = vb2_dqbuf(&layer->buffer_queue, buf, 1); | ||
1236 | else | ||
1237 | /* Call videobuf_dqbuf for blocking mode */ | ||
1238 | ret = vb2_dqbuf(&layer->buffer_queue, buf, 0); | ||
1239 | |||
1240 | return ret; | ||
1241 | } | ||
1242 | |||
1243 | static int vpbe_display_qbuf(struct file *file, void *priv, | ||
1244 | struct v4l2_buffer *p) | ||
1245 | { | ||
1246 | struct vpbe_layer *layer = video_drvdata(file); | ||
1247 | struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev; | ||
1248 | |||
1249 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, | ||
1250 | "VIDIOC_QBUF, layer id = %d\n", | ||
1251 | layer->device_id); | ||
1252 | |||
1253 | if (V4L2_BUF_TYPE_VIDEO_OUTPUT != p->type) { | ||
1254 | v4l2_err(&vpbe_dev->v4l2_dev, "Invalid buffer type\n"); | ||
1255 | return -EINVAL; | ||
1256 | } | ||
1257 | |||
1258 | return vb2_qbuf(&layer->buffer_queue, p); | ||
1259 | } | ||
1260 | |||
1261 | static int vpbe_display_querybuf(struct file *file, void *priv, | ||
1262 | struct v4l2_buffer *buf) | ||
1263 | { | ||
1264 | struct vpbe_layer *layer = video_drvdata(file); | ||
1265 | struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev; | ||
1266 | |||
1267 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, | ||
1268 | "VIDIOC_QUERYBUF, layer id = %d\n", | ||
1269 | layer->device_id); | ||
1270 | |||
1271 | if (V4L2_BUF_TYPE_VIDEO_OUTPUT != buf->type) { | ||
1272 | v4l2_err(&vpbe_dev->v4l2_dev, "Invalid buffer type\n"); | ||
1273 | return -EINVAL; | ||
1274 | } | ||
1275 | /* Call vb2_querybuf to get information */ | ||
1276 | return vb2_querybuf(&layer->buffer_queue, buf); | ||
1277 | } | ||
1278 | |||
1279 | static int vpbe_display_reqbufs(struct file *file, void *priv, | ||
1280 | struct v4l2_requestbuffers *req_buf) | ||
1281 | { | ||
1282 | struct vpbe_layer *layer = video_drvdata(file); | ||
1283 | struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev; | ||
1284 | |||
1285 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "vpbe_display_reqbufs\n"); | ||
1286 | |||
1287 | if (V4L2_BUF_TYPE_VIDEO_OUTPUT != req_buf->type) { | ||
1288 | v4l2_err(&vpbe_dev->v4l2_dev, "Invalid buffer type\n"); | ||
1289 | return -EINVAL; | ||
1290 | } | ||
1291 | |||
1292 | /* If io users of the layer is not zero, return error */ | ||
1293 | if (0 != layer->io_usrs) { | ||
1294 | v4l2_err(&vpbe_dev->v4l2_dev, "not IO user\n"); | ||
1295 | return -EBUSY; | ||
1296 | } | ||
1297 | /* Increment io usrs member of layer object to 1 */ | ||
1298 | layer->io_usrs = 1; | ||
1299 | /* Store type of memory requested in layer object */ | ||
1300 | layer->memory = req_buf->memory; | ||
1301 | /* Allocate buffers */ | ||
1302 | return vb2_reqbufs(&layer->buffer_queue, req_buf); | ||
1303 | } | ||
1304 | |||
1305 | /* | 1153 | /* |
1306 | * vpbe_display_open() | 1154 | * vpbe_display_open() |
1307 | * It creates object of file handle structure and stores it in private_data | 1155 | * It creates object of file handle structure and stores it in private_data |
@@ -1405,12 +1253,14 @@ static const struct v4l2_ioctl_ops vpbe_ioctl_ops = { | |||
1405 | .vidioc_enum_fmt_vid_out = vpbe_display_enum_fmt, | 1253 | .vidioc_enum_fmt_vid_out = vpbe_display_enum_fmt, |
1406 | .vidioc_s_fmt_vid_out = vpbe_display_s_fmt, | 1254 | .vidioc_s_fmt_vid_out = vpbe_display_s_fmt, |
1407 | .vidioc_try_fmt_vid_out = vpbe_display_try_fmt, | 1255 | .vidioc_try_fmt_vid_out = vpbe_display_try_fmt, |
1408 | .vidioc_reqbufs = vpbe_display_reqbufs, | 1256 | |
1409 | .vidioc_querybuf = vpbe_display_querybuf, | 1257 | .vidioc_reqbufs = vb2_ioctl_reqbufs, |
1410 | .vidioc_qbuf = vpbe_display_qbuf, | 1258 | .vidioc_querybuf = vb2_ioctl_querybuf, |
1411 | .vidioc_dqbuf = vpbe_display_dqbuf, | 1259 | .vidioc_qbuf = vb2_ioctl_qbuf, |
1412 | .vidioc_streamon = vpbe_display_streamon, | 1260 | .vidioc_dqbuf = vb2_ioctl_dqbuf, |
1413 | .vidioc_streamoff = vpbe_display_streamoff, | 1261 | .vidioc_streamon = vb2_ioctl_streamon, |
1262 | .vidioc_streamoff = vb2_ioctl_streamoff, | ||
1263 | |||
1414 | .vidioc_cropcap = vpbe_display_cropcap, | 1264 | .vidioc_cropcap = vpbe_display_cropcap, |
1415 | .vidioc_g_crop = vpbe_display_g_crop, | 1265 | .vidioc_g_crop = vpbe_display_g_crop, |
1416 | .vidioc_s_crop = vpbe_display_s_crop, | 1266 | .vidioc_s_crop = vpbe_display_s_crop, |