| .. | .. |
|---|
| 375 | 375 | } |
|---|
| 376 | 376 | spin_unlock_irqrestore(&s->irqlock, flags); |
|---|
| 377 | 377 | |
|---|
| 378 | | - /* Wait 100 milisecond for DMA to finish, abort on timeout. */ |
|---|
| 378 | + /* Wait 100 millisecond for DMA to finish, abort on timeout. */ |
|---|
| 379 | 379 | if (!wait_event_timeout(s->q.done_wq, is_dma_done(s), |
|---|
| 380 | 380 | msecs_to_jiffies(timeout_msec))) { |
|---|
| 381 | 381 | omni_sg_dma_abort_channel(s); |
|---|
| .. | .. |
|---|
| 479 | 479 | struct cobalt_stream *s = video_drvdata(file); |
|---|
| 480 | 480 | struct cobalt *cobalt = s->cobalt; |
|---|
| 481 | 481 | |
|---|
| 482 | | - strlcpy(vcap->driver, "cobalt", sizeof(vcap->driver)); |
|---|
| 483 | | - strlcpy(vcap->card, "cobalt", sizeof(vcap->card)); |
|---|
| 482 | + strscpy(vcap->driver, "cobalt", sizeof(vcap->driver)); |
|---|
| 483 | + strscpy(vcap->card, "cobalt", sizeof(vcap->card)); |
|---|
| 484 | 484 | snprintf(vcap->bus_info, sizeof(vcap->bus_info), |
|---|
| 485 | 485 | "PCIe:%s", pci_name(cobalt->pci_dev)); |
|---|
| 486 | | - vcap->device_caps = V4L2_CAP_STREAMING | V4L2_CAP_READWRITE; |
|---|
| 487 | | - if (s->is_output) |
|---|
| 488 | | - vcap->device_caps |= V4L2_CAP_VIDEO_OUTPUT; |
|---|
| 489 | | - else |
|---|
| 490 | | - vcap->device_caps |= V4L2_CAP_VIDEO_CAPTURE; |
|---|
| 491 | | - vcap->capabilities = vcap->device_caps | V4L2_CAP_DEVICE_CAPS | |
|---|
| 492 | | - V4L2_CAP_VIDEO_CAPTURE; |
|---|
| 486 | + vcap->capabilities = V4L2_CAP_STREAMING | V4L2_CAP_READWRITE | |
|---|
| 487 | + V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_DEVICE_CAPS; |
|---|
| 493 | 488 | if (cobalt->have_hsma_tx) |
|---|
| 494 | 489 | vcap->capabilities |= V4L2_CAP_VIDEO_OUTPUT; |
|---|
| 495 | 490 | return 0; |
|---|
| .. | .. |
|---|
| 693 | 688 | { |
|---|
| 694 | 689 | switch (f->index) { |
|---|
| 695 | 690 | case 0: |
|---|
| 696 | | - strlcpy(f->description, "YUV 4:2:2", sizeof(f->description)); |
|---|
| 697 | 691 | f->pixelformat = V4L2_PIX_FMT_YUYV; |
|---|
| 698 | 692 | break; |
|---|
| 699 | 693 | case 1: |
|---|
| 700 | | - strlcpy(f->description, "RGB24", sizeof(f->description)); |
|---|
| 701 | 694 | f->pixelformat = V4L2_PIX_FMT_RGB24; |
|---|
| 702 | 695 | break; |
|---|
| 703 | 696 | case 2: |
|---|
| 704 | | - strlcpy(f->description, "RGB32", sizeof(f->description)); |
|---|
| 705 | 697 | f->pixelformat = V4L2_PIX_FMT_BGR32; |
|---|
| 706 | 698 | break; |
|---|
| 707 | 699 | default: |
|---|
| .. | .. |
|---|
| 793 | 785 | |
|---|
| 794 | 786 | pix->sizeimage = pix->bytesperline * pix->height; |
|---|
| 795 | 787 | pix->field = V4L2_FIELD_NONE; |
|---|
| 796 | | - pix->priv = 0; |
|---|
| 797 | 788 | |
|---|
| 798 | 789 | return 0; |
|---|
| 799 | 790 | } |
|---|
| .. | .. |
|---|
| 898 | 889 | { |
|---|
| 899 | 890 | switch (f->index) { |
|---|
| 900 | 891 | case 0: |
|---|
| 901 | | - strlcpy(f->description, "YUV 4:2:2", sizeof(f->description)); |
|---|
| 902 | 892 | f->pixelformat = V4L2_PIX_FMT_YUYV; |
|---|
| 903 | 893 | break; |
|---|
| 904 | 894 | case 1: |
|---|
| 905 | | - strlcpy(f->description, "RGB32", sizeof(f->description)); |
|---|
| 906 | 895 | f->pixelformat = V4L2_PIX_FMT_BGR32; |
|---|
| 907 | 896 | break; |
|---|
| 908 | 897 | default: |
|---|
| .. | .. |
|---|
| 1064 | 1053 | |
|---|
| 1065 | 1054 | static int cobalt_g_parm(struct file *file, void *fh, struct v4l2_streamparm *a) |
|---|
| 1066 | 1055 | { |
|---|
| 1056 | + struct cobalt_stream *s = video_drvdata(file); |
|---|
| 1057 | + struct v4l2_fract fps; |
|---|
| 1058 | + |
|---|
| 1067 | 1059 | if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
|---|
| 1068 | 1060 | return -EINVAL; |
|---|
| 1069 | | - a->parm.capture.timeperframe.numerator = 1; |
|---|
| 1070 | | - a->parm.capture.timeperframe.denominator = 60; |
|---|
| 1061 | + |
|---|
| 1062 | + fps = v4l2_calc_timeperframe(&s->timings); |
|---|
| 1063 | + a->parm.capture.timeperframe.numerator = fps.numerator; |
|---|
| 1064 | + a->parm.capture.timeperframe.denominator = fps.denominator; |
|---|
| 1071 | 1065 | a->parm.capture.readbuffers = 3; |
|---|
| 1072 | 1066 | return 0; |
|---|
| 1073 | 1067 | } |
|---|
| 1074 | 1068 | |
|---|
| 1075 | | -static int cobalt_cropcap(struct file *file, void *fh, struct v4l2_cropcap *cc) |
|---|
| 1069 | +static int cobalt_g_pixelaspect(struct file *file, void *fh, |
|---|
| 1070 | + int type, struct v4l2_fract *f) |
|---|
| 1076 | 1071 | { |
|---|
| 1077 | 1072 | struct cobalt_stream *s = video_drvdata(file); |
|---|
| 1078 | 1073 | struct v4l2_dv_timings timings; |
|---|
| 1079 | 1074 | int err = 0; |
|---|
| 1080 | 1075 | |
|---|
| 1081 | | - if (cc->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
|---|
| 1076 | + if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
|---|
| 1082 | 1077 | return -EINVAL; |
|---|
| 1078 | + |
|---|
| 1083 | 1079 | if (s->input == 1) |
|---|
| 1084 | 1080 | timings = cea1080p60; |
|---|
| 1085 | 1081 | else |
|---|
| 1086 | 1082 | err = v4l2_subdev_call(s->sd, video, g_dv_timings, &timings); |
|---|
| 1087 | | - if (!err) { |
|---|
| 1088 | | - cc->bounds.width = cc->defrect.width = timings.bt.width; |
|---|
| 1089 | | - cc->bounds.height = cc->defrect.height = timings.bt.height; |
|---|
| 1090 | | - cc->pixelaspect = v4l2_dv_timings_aspect_ratio(&timings); |
|---|
| 1091 | | - } |
|---|
| 1083 | + if (!err) |
|---|
| 1084 | + *f = v4l2_dv_timings_aspect_ratio(&timings); |
|---|
| 1092 | 1085 | return err; |
|---|
| 1086 | +} |
|---|
| 1087 | + |
|---|
| 1088 | +static int cobalt_g_selection(struct file *file, void *fh, |
|---|
| 1089 | + struct v4l2_selection *sel) |
|---|
| 1090 | +{ |
|---|
| 1091 | + struct cobalt_stream *s = video_drvdata(file); |
|---|
| 1092 | + struct v4l2_dv_timings timings; |
|---|
| 1093 | + int err = 0; |
|---|
| 1094 | + |
|---|
| 1095 | + if (sel->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
|---|
| 1096 | + return -EINVAL; |
|---|
| 1097 | + |
|---|
| 1098 | + if (s->input == 1) |
|---|
| 1099 | + timings = cea1080p60; |
|---|
| 1100 | + else |
|---|
| 1101 | + err = v4l2_subdev_call(s->sd, video, g_dv_timings, &timings); |
|---|
| 1102 | + |
|---|
| 1103 | + if (err) |
|---|
| 1104 | + return err; |
|---|
| 1105 | + |
|---|
| 1106 | + switch (sel->target) { |
|---|
| 1107 | + case V4L2_SEL_TGT_CROP_BOUNDS: |
|---|
| 1108 | + case V4L2_SEL_TGT_CROP_DEFAULT: |
|---|
| 1109 | + sel->r.top = 0; |
|---|
| 1110 | + sel->r.left = 0; |
|---|
| 1111 | + sel->r.width = timings.bt.width; |
|---|
| 1112 | + sel->r.height = timings.bt.height; |
|---|
| 1113 | + break; |
|---|
| 1114 | + default: |
|---|
| 1115 | + return -EINVAL; |
|---|
| 1116 | + } |
|---|
| 1117 | + return 0; |
|---|
| 1093 | 1118 | } |
|---|
| 1094 | 1119 | |
|---|
| 1095 | 1120 | static const struct v4l2_ioctl_ops cobalt_ioctl_ops = { |
|---|
| .. | .. |
|---|
| 1098 | 1123 | .vidioc_log_status = cobalt_log_status, |
|---|
| 1099 | 1124 | .vidioc_streamon = vb2_ioctl_streamon, |
|---|
| 1100 | 1125 | .vidioc_streamoff = vb2_ioctl_streamoff, |
|---|
| 1101 | | - .vidioc_cropcap = cobalt_cropcap, |
|---|
| 1126 | + .vidioc_g_pixelaspect = cobalt_g_pixelaspect, |
|---|
| 1127 | + .vidioc_g_selection = cobalt_g_selection, |
|---|
| 1102 | 1128 | .vidioc_enum_input = cobalt_enum_input, |
|---|
| 1103 | 1129 | .vidioc_g_input = cobalt_g_input, |
|---|
| 1104 | 1130 | .vidioc_s_input = cobalt_s_input, |
|---|
| .. | .. |
|---|
| 1237 | 1263 | q->lock = &s->lock; |
|---|
| 1238 | 1264 | q->dev = &cobalt->pci_dev->dev; |
|---|
| 1239 | 1265 | vdev->queue = q; |
|---|
| 1266 | + vdev->device_caps = V4L2_CAP_STREAMING | V4L2_CAP_READWRITE; |
|---|
| 1267 | + if (s->is_output) |
|---|
| 1268 | + vdev->device_caps |= V4L2_CAP_VIDEO_OUTPUT; |
|---|
| 1269 | + else |
|---|
| 1270 | + vdev->device_caps |= V4L2_CAP_VIDEO_CAPTURE; |
|---|
| 1240 | 1271 | |
|---|
| 1241 | 1272 | video_set_drvdata(vdev, s); |
|---|
| 1242 | 1273 | ret = vb2_queue_init(q); |
|---|
| 1243 | 1274 | if (!s->is_audio && ret == 0) |
|---|
| 1244 | | - ret = video_register_device(vdev, VFL_TYPE_GRABBER, -1); |
|---|
| 1275 | + ret = video_register_device(vdev, VFL_TYPE_VIDEO, -1); |
|---|
| 1245 | 1276 | else if (!s->is_dummy) |
|---|
| 1246 | 1277 | ret = cobalt_alsa_init(s); |
|---|
| 1247 | 1278 | |
|---|