hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/drivers/media/platform/exynos-gsc/gsc-m2m.c
....@@ -1,13 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Copyright (c) 2011 - 2012 Samsung Electronics Co., Ltd.
34 * http://www.samsung.com
45 *
56 * Samsung EXYNOS5 SoC series G-Scaler driver
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License as published
9
- * by the Free Software Foundation, either version 2 of the License,
10
- * or (at your option) any later version.
117 */
128
139 #include <linux/module.h>
....@@ -60,10 +56,8 @@
6056 static int gsc_m2m_start_streaming(struct vb2_queue *q, unsigned int count)
6157 {
6258 struct gsc_ctx *ctx = q->drv_priv;
63
- int ret;
6459
65
- ret = pm_runtime_get_sync(&ctx->gsc_dev->pdev->dev);
66
- return ret > 0 ? 0 : ret;
60
+ return pm_runtime_resume_and_get(&ctx->gsc_dev->pdev->dev);
6761 }
6862
6963 static void __gsc_m2m_cleanup_queue(struct gsc_ctx *ctx)
....@@ -259,7 +253,7 @@
259253 if (IS_ERR(frame))
260254 return PTR_ERR(frame);
261255
262
- if (!V4L2_TYPE_IS_OUTPUT(vb->vb2_queue->type)) {
256
+ if (V4L2_TYPE_IS_CAPTURE(vb->vb2_queue->type)) {
263257 for (i = 0; i < frame->fmt->num_planes; i++)
264258 vb2_set_plane_payload(vb, i, frame->payload[i]);
265259 }
....@@ -294,19 +288,17 @@
294288 struct gsc_ctx *ctx = fh_to_ctx(fh);
295289 struct gsc_dev *gsc = ctx->gsc_dev;
296290
297
- strlcpy(cap->driver, GSC_MODULE_NAME, sizeof(cap->driver));
298
- strlcpy(cap->card, GSC_MODULE_NAME " gscaler", sizeof(cap->card));
291
+ strscpy(cap->driver, GSC_MODULE_NAME, sizeof(cap->driver));
292
+ strscpy(cap->card, GSC_MODULE_NAME " gscaler", sizeof(cap->card));
299293 snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
300294 dev_name(&gsc->pdev->dev));
301
- cap->device_caps = V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_M2M_MPLANE;
302
- cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
303295 return 0;
304296 }
305297
306
-static int gsc_m2m_enum_fmt_mplane(struct file *file, void *priv,
307
- struct v4l2_fmtdesc *f)
298
+static int gsc_m2m_enum_fmt(struct file *file, void *priv,
299
+ struct v4l2_fmtdesc *f)
308300 {
309
- return gsc_enum_fmt_mplane(f);
301
+ return gsc_enum_fmt(f);
310302 }
311303
312304 static int gsc_m2m_g_fmt_mplane(struct file *file, void *fh,
....@@ -494,30 +486,27 @@
494486 {
495487 struct gsc_frame *frame;
496488 struct gsc_ctx *ctx = fh_to_ctx(fh);
497
- struct v4l2_crop cr;
498489 struct gsc_variant *variant = ctx->gsc_dev->variant;
490
+ struct v4l2_selection sel = *s;
499491 int ret;
500
-
501
- cr.type = s->type;
502
- cr.c = s->r;
503492
504493 if ((s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) &&
505494 (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT))
506495 return -EINVAL;
507496
508
- ret = gsc_try_crop(ctx, &cr);
497
+ ret = gsc_try_selection(ctx, &sel);
509498 if (ret)
510499 return ret;
511500
512501 if (s->flags & V4L2_SEL_FLAG_LE &&
513
- !is_rectangle_enclosed(&cr.c, &s->r))
502
+ !is_rectangle_enclosed(&sel.r, &s->r))
514503 return -ERANGE;
515504
516505 if (s->flags & V4L2_SEL_FLAG_GE &&
517
- !is_rectangle_enclosed(&s->r, &cr.c))
506
+ !is_rectangle_enclosed(&s->r, &sel.r))
518507 return -ERANGE;
519508
520
- s->r = cr.c;
509
+ s->r = sel.r;
521510
522511 switch (s->target) {
523512 case V4L2_SEL_TGT_COMPOSE_BOUNDS:
....@@ -539,15 +528,15 @@
539528 /* Check to see if scaling ratio is within supported range */
540529 if (gsc_ctx_state_is_set(GSC_DST_FMT | GSC_SRC_FMT, ctx)) {
541530 if (s->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
542
- ret = gsc_check_scaler_ratio(variant, cr.c.width,
543
- cr.c.height, ctx->d_frame.crop.width,
531
+ ret = gsc_check_scaler_ratio(variant, sel.r.width,
532
+ sel.r.height, ctx->d_frame.crop.width,
544533 ctx->d_frame.crop.height,
545534 ctx->gsc_ctrls.rotate->val, ctx->out_path);
546535 } else {
547536 ret = gsc_check_scaler_ratio(variant,
548537 ctx->s_frame.crop.width,
549
- ctx->s_frame.crop.height, cr.c.width,
550
- cr.c.height, ctx->gsc_ctrls.rotate->val,
538
+ ctx->s_frame.crop.height, sel.r.width,
539
+ sel.r.height, ctx->gsc_ctrls.rotate->val,
551540 ctx->out_path);
552541 }
553542
....@@ -557,7 +546,7 @@
557546 }
558547 }
559548
560
- frame->crop = cr.c;
549
+ frame->crop = sel.r;
561550
562551 gsc_ctx_state_lock_set(GSC_PARAMS, ctx);
563552 return 0;
....@@ -565,8 +554,8 @@
565554
566555 static const struct v4l2_ioctl_ops gsc_m2m_ioctl_ops = {
567556 .vidioc_querycap = gsc_m2m_querycap,
568
- .vidioc_enum_fmt_vid_cap_mplane = gsc_m2m_enum_fmt_mplane,
569
- .vidioc_enum_fmt_vid_out_mplane = gsc_m2m_enum_fmt_mplane,
557
+ .vidioc_enum_fmt_vid_cap = gsc_m2m_enum_fmt,
558
+ .vidioc_enum_fmt_vid_out = gsc_m2m_enum_fmt,
570559 .vidioc_g_fmt_vid_cap_mplane = gsc_m2m_g_fmt_mplane,
571560 .vidioc_g_fmt_vid_out_mplane = gsc_m2m_g_fmt_mplane,
572561 .vidioc_try_fmt_vid_cap_mplane = gsc_m2m_try_fmt_mplane,
....@@ -766,6 +755,8 @@
766755 gsc->vdev.lock = &gsc->lock;
767756 gsc->vdev.vfl_dir = VFL_DIR_M2M;
768757 gsc->vdev.v4l2_dev = &gsc->v4l2_dev;
758
+ gsc->vdev.device_caps = V4L2_CAP_STREAMING |
759
+ V4L2_CAP_VIDEO_M2M_MPLANE;
769760 snprintf(gsc->vdev.name, sizeof(gsc->vdev.name), "%s.%d:m2m",
770761 GSC_MODULE_NAME, gsc->id);
771762
....@@ -778,7 +769,7 @@
778769 return PTR_ERR(gsc->m2m.m2m_dev);
779770 }
780771
781
- ret = video_register_device(&gsc->vdev, VFL_TYPE_GRABBER, -1);
772
+ ret = video_register_device(&gsc->vdev, VFL_TYPE_VIDEO, -1);
782773 if (ret) {
783774 dev_err(&pdev->dev,
784775 "%s(): failed to register video device\n", __func__);