aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/pci/cx18/cx18-ioctl.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@osg.samsung.com>2015-04-21 05:12:35 -0400
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2015-04-21 05:12:35 -0400
commit676ee36be04985062522804c2de04f0764212be6 (patch)
tree781df135c5a91a04decad1b7d53b5a925dc11522 /drivers/media/pci/cx18/cx18-ioctl.c
parentb18042a673e88c9457a6d1716219c2367ca447b0 (diff)
parente183201b9e917daf2530b637b2f34f1d5afb934d (diff)
Merge branch 'patchwork' into v4l_for_linus
* patchwork: (404 commits) [media] uvcvideo: add support for VIDIOC_QUERY_EXT_CTRL [media] uvcvideo: fix cropcap v4l2-compliance failure [media] media: omap3isp: remove unused clkdev [media] coda: Add tracing support [media] coda: drop dma_sync_single_for_device in coda_bitstream_queue [media] coda: fix fill bitstream errors in nonstreaming case [media] coda: call SEQ_END when the first queue is stopped [media] coda: fail to start streaming if userspace set invalid formats [media] coda: remove duplicate error messages for buffer allocations [media] coda: move parameter buffer in together with context buffer allocation [media] coda: allocate bitstream buffer from REQBUFS, size depends on the format [media] coda: allocate per-context buffers from REQBUFS [media] coda: use strlcpy instead of snprintf [media] coda: bitstream payload is unsigned [media] coda: fix double call to debugfs_remove [media] coda: check kasprintf return value in coda_open [media] coda: bitrate can only be set in kbps steps [media] v4l2-mem2mem: no need to initialize b in v4l2_m2m_next_buf and v4l2_m2m_buf_remove [media] s5p-mfc: set allow_zero_bytesused flag for vb2_queue_init [media] coda: set allow_zero_bytesused flag for vb2_queue_init ...
Diffstat (limited to 'drivers/media/pci/cx18/cx18-ioctl.c')
-rw-r--r--drivers/media/pci/cx18/cx18-ioctl.c58
1 files changed, 33 insertions, 25 deletions
diff --git a/drivers/media/pci/cx18/cx18-ioctl.c b/drivers/media/pci/cx18/cx18-ioctl.c
index b8e4b68a9196..79aee30d5fd8 100644
--- a/drivers/media/pci/cx18/cx18-ioctl.c
+++ b/drivers/media/pci/cx18/cx18-ioctl.c
@@ -39,6 +39,7 @@
39#include "cx18-cards.h" 39#include "cx18-cards.h"
40#include "cx18-av-core.h" 40#include "cx18-av-core.h"
41#include <media/tveeprom.h> 41#include <media/tveeprom.h>
42#include <media/v4l2-event.h>
42 43
43u16 cx18_service2vbi(int type) 44u16 cx18_service2vbi(int type)
44{ 45{
@@ -159,7 +160,7 @@ static int cx18_g_fmt_vid_cap(struct file *file, void *fh,
159 if (id->type == CX18_ENC_STREAM_TYPE_YUV) { 160 if (id->type == CX18_ENC_STREAM_TYPE_YUV) {
160 pixfmt->pixelformat = s->pixelformat; 161 pixfmt->pixelformat = s->pixelformat;
161 pixfmt->sizeimage = s->vb_bytes_per_frame; 162 pixfmt->sizeimage = s->vb_bytes_per_frame;
162 pixfmt->bytesperline = 720; 163 pixfmt->bytesperline = s->vb_bytes_per_line;
163 } else { 164 } else {
164 pixfmt->pixelformat = V4L2_PIX_FMT_MPEG; 165 pixfmt->pixelformat = V4L2_PIX_FMT_MPEG;
165 pixfmt->sizeimage = 128 * 1024; 166 pixfmt->sizeimage = 128 * 1024;
@@ -287,10 +288,13 @@ static int cx18_s_fmt_vid_cap(struct file *file, void *fh,
287 s->pixelformat = fmt->fmt.pix.pixelformat; 288 s->pixelformat = fmt->fmt.pix.pixelformat;
288 /* HM12 YUV size is (Y=(h*720) + UV=(h*(720/2))) 289 /* HM12 YUV size is (Y=(h*720) + UV=(h*(720/2)))
289 UYUV YUV size is (Y=(h*720) + UV=(h*(720))) */ 290 UYUV YUV size is (Y=(h*720) + UV=(h*(720))) */
290 if (s->pixelformat == V4L2_PIX_FMT_HM12) 291 if (s->pixelformat == V4L2_PIX_FMT_HM12) {
291 s->vb_bytes_per_frame = h * 720 * 3 / 2; 292 s->vb_bytes_per_frame = h * 720 * 3 / 2;
292 else 293 s->vb_bytes_per_line = 720; /* First plane */
294 } else {
293 s->vb_bytes_per_frame = h * 720 * 2; 295 s->vb_bytes_per_frame = h * 720 * 2;
296 s->vb_bytes_per_line = 1440; /* Packed */
297 }
294 298
295 mbus_fmt.width = cx->cxhdl.width = w; 299 mbus_fmt.width = cx->cxhdl.width = w;
296 mbus_fmt.height = cx->cxhdl.height = h; 300 mbus_fmt.height = cx->cxhdl.height = h;
@@ -447,34 +451,29 @@ static int cx18_cropcap(struct file *file, void *fh,
447 451
448 if (cropcap->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 452 if (cropcap->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
449 return -EINVAL; 453 return -EINVAL;
450 cropcap->bounds.top = cropcap->bounds.left = 0;
451 cropcap->bounds.width = 720;
452 cropcap->bounds.height = cx->is_50hz ? 576 : 480;
453 cropcap->pixelaspect.numerator = cx->is_50hz ? 59 : 10; 454 cropcap->pixelaspect.numerator = cx->is_50hz ? 59 : 10;
454 cropcap->pixelaspect.denominator = cx->is_50hz ? 54 : 11; 455 cropcap->pixelaspect.denominator = cx->is_50hz ? 54 : 11;
455 cropcap->defrect = cropcap->bounds;
456 return 0; 456 return 0;
457} 457}
458 458
459static int cx18_s_crop(struct file *file, void *fh, const struct v4l2_crop *crop) 459static int cx18_g_selection(struct file *file, void *fh,
460{ 460 struct v4l2_selection *sel)
461 struct cx18_open_id *id = fh2id(fh);
462 struct cx18 *cx = id->cx;
463
464 if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
465 return -EINVAL;
466 CX18_DEBUG_WARN("VIDIOC_S_CROP not implemented\n");
467 return -EINVAL;
468}
469
470static int cx18_g_crop(struct file *file, void *fh, struct v4l2_crop *crop)
471{ 461{
472 struct cx18 *cx = fh2id(fh)->cx; 462 struct cx18 *cx = fh2id(fh)->cx;
473 463
474 if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 464 if (sel->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
475 return -EINVAL; 465 return -EINVAL;
476 CX18_DEBUG_WARN("VIDIOC_G_CROP not implemented\n"); 466 switch (sel->target) {
477 return -EINVAL; 467 case V4L2_SEL_TGT_CROP_BOUNDS:
468 case V4L2_SEL_TGT_CROP_DEFAULT:
469 sel->r.top = sel->r.left = 0;
470 sel->r.width = 720;
471 sel->r.height = cx->is_50hz ? 576 : 480;
472 break;
473 default:
474 return -EINVAL;
475 }
476 return 0;
478} 477}
479 478
480static int cx18_enum_fmt_vid_cap(struct file *file, void *fh, 479static int cx18_enum_fmt_vid_cap(struct file *file, void *fh,
@@ -510,6 +509,9 @@ int cx18_s_input(struct file *file, void *fh, unsigned int inp)
510{ 509{
511 struct cx18_open_id *id = fh2id(fh); 510 struct cx18_open_id *id = fh2id(fh);
512 struct cx18 *cx = id->cx; 511 struct cx18 *cx = id->cx;
512 v4l2_std_id std = V4L2_STD_ALL;
513 const struct cx18_card_video_input *card_input =
514 cx->card->video_inputs + inp;
513 515
514 if (inp >= cx->nof_inputs) 516 if (inp >= cx->nof_inputs)
515 return -EINVAL; 517 return -EINVAL;
@@ -525,6 +527,11 @@ int cx18_s_input(struct file *file, void *fh, unsigned int inp)
525 cx->active_input = inp; 527 cx->active_input = inp;
526 /* Set the audio input to whatever is appropriate for the input type. */ 528 /* Set the audio input to whatever is appropriate for the input type. */
527 cx->audio_input = cx->card->video_inputs[inp].audio_index; 529 cx->audio_input = cx->card->video_inputs[inp].audio_index;
530 if (card_input->video_type == V4L2_INPUT_TYPE_TUNER)
531 std = cx->tuner_std;
532 cx->streams[CX18_ENC_STREAM_TYPE_MPG].video_dev.tvnorms = std;
533 cx->streams[CX18_ENC_STREAM_TYPE_YUV].video_dev.tvnorms = std;
534 cx->streams[CX18_ENC_STREAM_TYPE_VBI].video_dev.tvnorms = std;
528 535
529 /* prevent others from messing with the streams until 536 /* prevent others from messing with the streams until
530 we're finished changing inputs. */ 537 we're finished changing inputs. */
@@ -1036,7 +1043,7 @@ static int cx18_log_status(struct file *file, void *fh)
1036 for (i = 0; i < CX18_MAX_STREAMS; i++) { 1043 for (i = 0; i < CX18_MAX_STREAMS; i++) {
1037 struct cx18_stream *s = &cx->streams[i]; 1044 struct cx18_stream *s = &cx->streams[i];
1038 1045
1039 if (s->video_dev == NULL || s->buffers == 0) 1046 if (s->video_dev.v4l2_dev == NULL || s->buffers == 0)
1040 continue; 1047 continue;
1041 CX18_INFO("Stream %s: status 0x%04lx, %d%% of %d KiB (%d buffers) in use\n", 1048 CX18_INFO("Stream %s: status 0x%04lx, %d%% of %d KiB (%d buffers) in use\n",
1042 s->name, s->s_flags, 1049 s->name, s->s_flags,
@@ -1078,8 +1085,7 @@ static const struct v4l2_ioctl_ops cx18_ioctl_ops = {
1078 .vidioc_enumaudio = cx18_enumaudio, 1085 .vidioc_enumaudio = cx18_enumaudio,
1079 .vidioc_enum_input = cx18_enum_input, 1086 .vidioc_enum_input = cx18_enum_input,
1080 .vidioc_cropcap = cx18_cropcap, 1087 .vidioc_cropcap = cx18_cropcap,
1081 .vidioc_s_crop = cx18_s_crop, 1088 .vidioc_g_selection = cx18_g_selection,
1082 .vidioc_g_crop = cx18_g_crop,
1083 .vidioc_g_input = cx18_g_input, 1089 .vidioc_g_input = cx18_g_input,
1084 .vidioc_s_input = cx18_s_input, 1090 .vidioc_s_input = cx18_s_input,
1085 .vidioc_g_frequency = cx18_g_frequency, 1091 .vidioc_g_frequency = cx18_g_frequency,
@@ -1114,6 +1120,8 @@ static const struct v4l2_ioctl_ops cx18_ioctl_ops = {
1114 .vidioc_querybuf = cx18_querybuf, 1120 .vidioc_querybuf = cx18_querybuf,
1115 .vidioc_qbuf = cx18_qbuf, 1121 .vidioc_qbuf = cx18_qbuf,
1116 .vidioc_dqbuf = cx18_dqbuf, 1122 .vidioc_dqbuf = cx18_dqbuf,
1123 .vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
1124 .vidioc_unsubscribe_event = v4l2_event_unsubscribe,
1117}; 1125};
1118 1126
1119void cx18_set_funcs(struct video_device *vdev) 1127void cx18_set_funcs(struct video_device *vdev)