forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/media/pci/cx18/cx18-ioctl.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * cx18 ioctl system call
34 *
....@@ -5,16 +6,6 @@
56 *
67 * Copyright (C) 2007 Hans Verkuil <hverkuil@xs4all.nl>
78 * Copyright (C) 2008 Andy Walls <awalls@md.metrocast.net>
8
- *
9
- * This program is free software; you can redistribute it and/or modify
10
- * it under the terms of the GNU General Public License as published by
11
- * the Free Software Foundation; either version 2 of the License, or
12
- * (at your option) any later version.
13
- *
14
- * This program is distributed in the hope that it will be useful,
15
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
- * GNU General Public License for more details.
189 */
1910
2011 #include "cx18-driver.h"
....@@ -87,7 +78,7 @@
8778 return 0;
8879 }
8980 for (i = 0; i < 32; i++) {
90
- if ((1 << i) & set)
81
+ if (BIT(i) & set)
9182 return 1 << i;
9283 }
9384 return 0;
....@@ -394,16 +385,13 @@
394385 struct v4l2_capability *vcap)
395386 {
396387 struct cx18_open_id *id = fh2id(fh);
397
- struct cx18_stream *s = video_drvdata(file);
398388 struct cx18 *cx = id->cx;
399389
400
- strlcpy(vcap->driver, CX18_DRIVER_NAME, sizeof(vcap->driver));
401
- strlcpy(vcap->card, cx->card_name, sizeof(vcap->card));
390
+ strscpy(vcap->driver, CX18_DRIVER_NAME, sizeof(vcap->driver));
391
+ strscpy(vcap->card, cx->card_name, sizeof(vcap->card));
402392 snprintf(vcap->bus_info, sizeof(vcap->bus_info),
403393 "PCI:%s", pci_name(cx->pci_dev));
404
- vcap->capabilities = cx->v4l2_cap; /* capabilities */
405
- vcap->device_caps = s->v4l2_dev_caps; /* device capabilities */
406
- vcap->capabilities |= V4L2_CAP_DEVICE_CAPS;
394
+ vcap->capabilities = cx->v4l2_cap | V4L2_CAP_DEVICE_CAPS;
407395 return 0;
408396 }
409397
....@@ -441,15 +429,16 @@
441429 return cx18_get_input(cx, vin->index, vin);
442430 }
443431
444
-static int cx18_cropcap(struct file *file, void *fh,
445
- struct v4l2_cropcap *cropcap)
432
+static int cx18_g_pixelaspect(struct file *file, void *fh,
433
+ int type, struct v4l2_fract *f)
446434 {
447435 struct cx18 *cx = fh2id(fh)->cx;
448436
449
- if (cropcap->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
437
+ if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
450438 return -EINVAL;
451
- cropcap->pixelaspect.numerator = cx->is_50hz ? 54 : 11;
452
- cropcap->pixelaspect.denominator = cx->is_50hz ? 59 : 10;
439
+
440
+ f->numerator = cx->is_50hz ? 54 : 11;
441
+ f->denominator = cx->is_50hz ? 59 : 10;
453442 return 0;
454443 }
455444
....@@ -477,14 +466,24 @@
477466 struct v4l2_fmtdesc *fmt)
478467 {
479468 static const struct v4l2_fmtdesc formats[] = {
480
- { 0, V4L2_BUF_TYPE_VIDEO_CAPTURE, 0,
481
- "HM12 (YUV 4:1:1)", V4L2_PIX_FMT_HM12, { 0, 0, 0, 0 }
469
+ {
470
+ .index = 0,
471
+ .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
472
+ .description = "HM12 (YUV 4:1:1)",
473
+ .pixelformat = V4L2_PIX_FMT_HM12,
482474 },
483
- { 1, V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FMT_FLAG_COMPRESSED,
484
- "MPEG", V4L2_PIX_FMT_MPEG, { 0, 0, 0, 0 }
475
+ {
476
+ .index = 1,
477
+ .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
478
+ .flags = V4L2_FMT_FLAG_COMPRESSED,
479
+ .description = "MPEG",
480
+ .pixelformat = V4L2_PIX_FMT_MPEG,
485481 },
486
- { 2, V4L2_BUF_TYPE_VIDEO_CAPTURE, 0,
487
- "UYVY 4:2:2", V4L2_PIX_FMT_UYVY, { 0, 0, 0, 0 }
482
+ {
483
+ .index = 2,
484
+ .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
485
+ .description = "UYVY 4:2:2",
486
+ .pixelformat = V4L2_PIX_FMT_UYVY,
488487 },
489488 };
490489
....@@ -632,9 +631,9 @@
632631 cx18_call_all(cx, tuner, g_tuner, vt);
633632
634633 if (vt->type == V4L2_TUNER_RADIO)
635
- strlcpy(vt->name, "cx18 Radio Tuner", sizeof(vt->name));
634
+ strscpy(vt->name, "cx18 Radio Tuner", sizeof(vt->name));
636635 else
637
- strlcpy(vt->name, "cx18 TV Tuner", sizeof(vt->name));
636
+ strscpy(vt->name, "cx18 TV Tuner", sizeof(vt->name));
638637 return 0;
639638 }
640639
....@@ -675,7 +674,7 @@
675674 struct cx18_enc_idx_entry *e_buf;
676675
677676 /* Frame type lookup: 1=I, 2=P, 4=B */
678
- const int mapping[8] = {
677
+ static const int mapping[8] = {
679678 -1, V4L2_ENC_IDX_FRAME_I, V4L2_ENC_IDX_FRAME_P,
680679 -1, V4L2_ENC_IDX_FRAME_B, -1, -1, -1
681680 };
....@@ -1079,7 +1078,7 @@
10791078 .vidioc_g_audio = cx18_g_audio,
10801079 .vidioc_enumaudio = cx18_enumaudio,
10811080 .vidioc_enum_input = cx18_enum_input,
1082
- .vidioc_cropcap = cx18_cropcap,
1081
+ .vidioc_g_pixelaspect = cx18_g_pixelaspect,
10831082 .vidioc_g_selection = cx18_g_selection,
10841083 .vidioc_g_input = cx18_g_input,
10851084 .vidioc_s_input = cx18_s_input,