2019-03-02 00:46:11 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2010-04-23 16:38:38 +08:00
|
|
|
/*
|
|
|
|
* A virtual v4l2-mem2mem example device.
|
|
|
|
*
|
|
|
|
* This is a virtual device driver for testing mem-to-mem videobuf framework.
|
|
|
|
* It simulates a device that uses memory buffers for both source and
|
2018-05-21 16:54:56 +08:00
|
|
|
* destination, processes the data and issues an "irq" (simulated by a delayed
|
|
|
|
* workqueue).
|
2010-04-23 16:38:38 +08:00
|
|
|
* The device is capable of multi-instance, multi-buffer-per-transaction
|
|
|
|
* operation (via the mem2mem framework).
|
|
|
|
*
|
|
|
|
* Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
|
2011-03-14 02:23:32 +08:00
|
|
|
* Pawel Osciak, <pawel@osciak.com>
|
2010-04-23 16:38:38 +08:00
|
|
|
* Marek Szyprowski, <m.szyprowski@samsung.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2 of the
|
|
|
|
* License, or (at your option) any later version
|
|
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/sched.h>
|
2010-05-08 02:22:26 +08:00
|
|
|
#include <linux/slab.h>
|
2010-04-23 16:38:38 +08:00
|
|
|
|
|
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <media/v4l2-mem2mem.h>
|
|
|
|
#include <media/v4l2-device.h>
|
|
|
|
#include <media/v4l2-ioctl.h>
|
2012-07-18 21:35:37 +08:00
|
|
|
#include <media/v4l2-ctrls.h>
|
2012-07-18 21:54:59 +08:00
|
|
|
#include <media/v4l2-event.h>
|
2011-01-12 17:50:55 +08:00
|
|
|
#include <media/videobuf2-vmalloc.h>
|
2010-04-23 16:38:38 +08:00
|
|
|
|
|
|
|
MODULE_DESCRIPTION("Virtual device for mem2mem framework testing");
|
2011-03-14 02:23:32 +08:00
|
|
|
MODULE_AUTHOR("Pawel Osciak, <pawel@osciak.com>");
|
2010-04-23 16:38:38 +08:00
|
|
|
MODULE_LICENSE("GPL");
|
2019-03-02 00:45:04 +08:00
|
|
|
MODULE_VERSION("0.2");
|
2014-09-22 20:27:17 +08:00
|
|
|
MODULE_ALIAS("mem2mem_testdev");
|
2010-04-23 16:38:38 +08:00
|
|
|
|
2019-03-02 00:45:04 +08:00
|
|
|
static unsigned int debug;
|
2013-04-17 14:04:10 +08:00
|
|
|
module_param(debug, uint, 0644);
|
2019-02-26 20:29:57 +08:00
|
|
|
MODULE_PARM_DESC(debug, "debug level");
|
2013-04-17 14:04:10 +08:00
|
|
|
|
2019-01-30 00:00:17 +08:00
|
|
|
/* Default transaction time in msec */
|
|
|
|
static unsigned int default_transtime = 40; /* Max 25 fps */
|
|
|
|
module_param(default_transtime, uint, 0644);
|
|
|
|
MODULE_PARM_DESC(default_transtime, "default transaction time in ms");
|
|
|
|
|
2010-04-23 16:38:38 +08:00
|
|
|
#define MIN_W 32
|
|
|
|
#define MIN_H 32
|
|
|
|
#define MAX_W 640
|
|
|
|
#define MAX_H 480
|
2019-02-28 14:25:50 +08:00
|
|
|
|
|
|
|
/* Pixel alignment for non-bayer formats */
|
|
|
|
#define WIDTH_ALIGN 2
|
|
|
|
#define HEIGHT_ALIGN 1
|
|
|
|
|
|
|
|
/* Pixel alignment for bayer formats */
|
|
|
|
#define BAYER_WIDTH_ALIGN 2
|
|
|
|
#define BAYER_HEIGHT_ALIGN 2
|
2010-04-23 16:38:38 +08:00
|
|
|
|
|
|
|
/* Flags that indicate a format can be used for capture/output */
|
2019-03-02 00:45:04 +08:00
|
|
|
#define MEM2MEM_CAPTURE BIT(0)
|
|
|
|
#define MEM2MEM_OUTPUT BIT(1)
|
2010-04-23 16:38:38 +08:00
|
|
|
|
2014-09-22 20:27:17 +08:00
|
|
|
#define MEM2MEM_NAME "vim2m"
|
2010-04-23 16:38:38 +08:00
|
|
|
|
|
|
|
/* Per queue */
|
|
|
|
#define MEM2MEM_DEF_NUM_BUFS VIDEO_MAX_FRAME
|
|
|
|
/* In bytes, per queue */
|
|
|
|
#define MEM2MEM_VID_MEM_LIMIT (16 * 1024 * 1024)
|
|
|
|
|
2012-06-12 17:43:49 +08:00
|
|
|
/* Flags that indicate processing mode */
|
2019-03-02 00:45:04 +08:00
|
|
|
#define MEM2MEM_HFLIP BIT(0)
|
|
|
|
#define MEM2MEM_VFLIP BIT(1)
|
2012-06-12 17:43:49 +08:00
|
|
|
|
2019-02-26 20:29:57 +08:00
|
|
|
#define dprintk(dev, lvl, fmt, arg...) \
|
|
|
|
v4l2_dbg(lvl, debug, &(dev)->v4l2_dev, "%s: " fmt, __func__, ## arg)
|
2010-04-23 16:38:38 +08:00
|
|
|
|
2014-09-22 20:27:17 +08:00
|
|
|
static void vim2m_dev_release(struct device *dev)
|
2010-04-23 16:38:38 +08:00
|
|
|
{}
|
|
|
|
|
2014-09-22 20:27:17 +08:00
|
|
|
static struct platform_device vim2m_pdev = {
|
2010-04-23 16:38:38 +08:00
|
|
|
.name = MEM2MEM_NAME,
|
2014-09-22 20:27:17 +08:00
|
|
|
.dev.release = vim2m_dev_release,
|
2010-04-23 16:38:38 +08:00
|
|
|
};
|
|
|
|
|
2014-09-22 20:27:17 +08:00
|
|
|
struct vim2m_fmt {
|
2010-04-23 16:38:38 +08:00
|
|
|
u32 fourcc;
|
|
|
|
int depth;
|
2019-02-01 20:58:46 +08:00
|
|
|
/* Types the format can be used for */
|
|
|
|
u32 types;
|
2010-04-23 16:38:38 +08:00
|
|
|
};
|
|
|
|
|
2014-09-22 20:27:17 +08:00
|
|
|
static struct vim2m_fmt formats[] = {
|
2010-04-23 16:38:38 +08:00
|
|
|
{
|
media: vim2m: fix driver for it to handle different fourcc formats
Despite vim2m is reporting that it supports RGB565BE and YUYV,
that's not true.
Right now, it just says that it supports both format, but it
doesn't actually support them.
Also, horizontal flip is not properly implemented. It sounds
that it was designed to do a pseudo-horizontal flip using 8
tiles. Yet, as it doesn't do format conversion, the result
is a mess.
I suspect that it was done this way in order to save CPU time,
at the time of OMAP2 days.
That's messy and doesn't really help if someone wants to
use vim2m to test a pipeline.
Worse than that, the unique RGB format it says it supports is
RGB565BE, with is not supported by Gstreamer. That prevents
practical usage of it, even for tests.
So, instead, properly implement fourcc format conversions,
adding a few more RGB formats:
- RGB and BGR with 24 bits
- RGB565LE (known as RGB16 at gstreamer)
Also allows using any of the 5 supported formats as either
capture or output.
Note: The YUYV conversion routines are based on the conversion code
written by Hans de Goede inside libv4lconvert (part of v4l-utils),
released under LGPGL 2.1 (GPL 2.0 compatible).
Tested all possible format combinations except for RGB565BE,
as Gstreamer currently doesn't support it.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-01-30 00:00:15 +08:00
|
|
|
.fourcc = V4L2_PIX_FMT_RGB565, /* rrrrrggg gggbbbbb */
|
2010-04-23 16:38:38 +08:00
|
|
|
.depth = 16,
|
2019-02-01 20:58:46 +08:00
|
|
|
.types = MEM2MEM_CAPTURE | MEM2MEM_OUTPUT,
|
media: vim2m: fix driver for it to handle different fourcc formats
Despite vim2m is reporting that it supports RGB565BE and YUYV,
that's not true.
Right now, it just says that it supports both format, but it
doesn't actually support them.
Also, horizontal flip is not properly implemented. It sounds
that it was designed to do a pseudo-horizontal flip using 8
tiles. Yet, as it doesn't do format conversion, the result
is a mess.
I suspect that it was done this way in order to save CPU time,
at the time of OMAP2 days.
That's messy and doesn't really help if someone wants to
use vim2m to test a pipeline.
Worse than that, the unique RGB format it says it supports is
RGB565BE, with is not supported by Gstreamer. That prevents
practical usage of it, even for tests.
So, instead, properly implement fourcc format conversions,
adding a few more RGB formats:
- RGB and BGR with 24 bits
- RGB565LE (known as RGB16 at gstreamer)
Also allows using any of the 5 supported formats as either
capture or output.
Note: The YUYV conversion routines are based on the conversion code
written by Hans de Goede inside libv4lconvert (part of v4l-utils),
released under LGPGL 2.1 (GPL 2.0 compatible).
Tested all possible format combinations except for RGB565BE,
as Gstreamer currently doesn't support it.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-01-30 00:00:15 +08:00
|
|
|
}, {
|
|
|
|
.fourcc = V4L2_PIX_FMT_RGB565X, /* gggbbbbb rrrrrggg */
|
|
|
|
.depth = 16,
|
2019-02-01 20:58:46 +08:00
|
|
|
.types = MEM2MEM_CAPTURE | MEM2MEM_OUTPUT,
|
media: vim2m: fix driver for it to handle different fourcc formats
Despite vim2m is reporting that it supports RGB565BE and YUYV,
that's not true.
Right now, it just says that it supports both format, but it
doesn't actually support them.
Also, horizontal flip is not properly implemented. It sounds
that it was designed to do a pseudo-horizontal flip using 8
tiles. Yet, as it doesn't do format conversion, the result
is a mess.
I suspect that it was done this way in order to save CPU time,
at the time of OMAP2 days.
That's messy and doesn't really help if someone wants to
use vim2m to test a pipeline.
Worse than that, the unique RGB format it says it supports is
RGB565BE, with is not supported by Gstreamer. That prevents
practical usage of it, even for tests.
So, instead, properly implement fourcc format conversions,
adding a few more RGB formats:
- RGB and BGR with 24 bits
- RGB565LE (known as RGB16 at gstreamer)
Also allows using any of the 5 supported formats as either
capture or output.
Note: The YUYV conversion routines are based on the conversion code
written by Hans de Goede inside libv4lconvert (part of v4l-utils),
released under LGPGL 2.1 (GPL 2.0 compatible).
Tested all possible format combinations except for RGB565BE,
as Gstreamer currently doesn't support it.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-01-30 00:00:15 +08:00
|
|
|
}, {
|
|
|
|
.fourcc = V4L2_PIX_FMT_RGB24,
|
|
|
|
.depth = 24,
|
2019-02-01 20:58:46 +08:00
|
|
|
.types = MEM2MEM_CAPTURE | MEM2MEM_OUTPUT,
|
media: vim2m: fix driver for it to handle different fourcc formats
Despite vim2m is reporting that it supports RGB565BE and YUYV,
that's not true.
Right now, it just says that it supports both format, but it
doesn't actually support them.
Also, horizontal flip is not properly implemented. It sounds
that it was designed to do a pseudo-horizontal flip using 8
tiles. Yet, as it doesn't do format conversion, the result
is a mess.
I suspect that it was done this way in order to save CPU time,
at the time of OMAP2 days.
That's messy and doesn't really help if someone wants to
use vim2m to test a pipeline.
Worse than that, the unique RGB format it says it supports is
RGB565BE, with is not supported by Gstreamer. That prevents
practical usage of it, even for tests.
So, instead, properly implement fourcc format conversions,
adding a few more RGB formats:
- RGB and BGR with 24 bits
- RGB565LE (known as RGB16 at gstreamer)
Also allows using any of the 5 supported formats as either
capture or output.
Note: The YUYV conversion routines are based on the conversion code
written by Hans de Goede inside libv4lconvert (part of v4l-utils),
released under LGPGL 2.1 (GPL 2.0 compatible).
Tested all possible format combinations except for RGB565BE,
as Gstreamer currently doesn't support it.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-01-30 00:00:15 +08:00
|
|
|
}, {
|
|
|
|
.fourcc = V4L2_PIX_FMT_BGR24,
|
|
|
|
.depth = 24,
|
2019-02-01 20:58:46 +08:00
|
|
|
.types = MEM2MEM_CAPTURE | MEM2MEM_OUTPUT,
|
media: vim2m: fix driver for it to handle different fourcc formats
Despite vim2m is reporting that it supports RGB565BE and YUYV,
that's not true.
Right now, it just says that it supports both format, but it
doesn't actually support them.
Also, horizontal flip is not properly implemented. It sounds
that it was designed to do a pseudo-horizontal flip using 8
tiles. Yet, as it doesn't do format conversion, the result
is a mess.
I suspect that it was done this way in order to save CPU time,
at the time of OMAP2 days.
That's messy and doesn't really help if someone wants to
use vim2m to test a pipeline.
Worse than that, the unique RGB format it says it supports is
RGB565BE, with is not supported by Gstreamer. That prevents
practical usage of it, even for tests.
So, instead, properly implement fourcc format conversions,
adding a few more RGB formats:
- RGB and BGR with 24 bits
- RGB565LE (known as RGB16 at gstreamer)
Also allows using any of the 5 supported formats as either
capture or output.
Note: The YUYV conversion routines are based on the conversion code
written by Hans de Goede inside libv4lconvert (part of v4l-utils),
released under LGPGL 2.1 (GPL 2.0 compatible).
Tested all possible format combinations except for RGB565BE,
as Gstreamer currently doesn't support it.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-01-30 00:00:15 +08:00
|
|
|
}, {
|
2010-04-23 16:38:38 +08:00
|
|
|
.fourcc = V4L2_PIX_FMT_YUYV,
|
|
|
|
.depth = 16,
|
media: vim2m: don't accept YUYV anymore as output format
Handling any Y,Cr,Cb formats require some extra logic, as it
handles a group of two pixels. That's easy while we don't do
horizontal scaling.
However, doing horizontal scaling with such formats would require
a lot more code, in order to avoid distortions, as, if it scales
to two non-consecutive points, the logic would need to read 4
points in order to properly convert to RGB.
As this is just a test driver, and we want fast algorithms,
let's just get rid of this format as an output one.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-03-01 20:41:24 +08:00
|
|
|
.types = MEM2MEM_CAPTURE,
|
2019-02-01 20:58:46 +08:00
|
|
|
}, {
|
|
|
|
.fourcc = V4L2_PIX_FMT_SBGGR8,
|
|
|
|
.depth = 8,
|
|
|
|
.types = MEM2MEM_CAPTURE,
|
|
|
|
}, {
|
|
|
|
.fourcc = V4L2_PIX_FMT_SGBRG8,
|
|
|
|
.depth = 8,
|
|
|
|
.types = MEM2MEM_CAPTURE,
|
|
|
|
}, {
|
|
|
|
.fourcc = V4L2_PIX_FMT_SGRBG8,
|
|
|
|
.depth = 8,
|
|
|
|
.types = MEM2MEM_CAPTURE,
|
|
|
|
}, {
|
|
|
|
.fourcc = V4L2_PIX_FMT_SRGGB8,
|
|
|
|
.depth = 8,
|
|
|
|
.types = MEM2MEM_CAPTURE,
|
2010-04-23 16:38:38 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2012-07-18 21:35:37 +08:00
|
|
|
#define NUM_FORMATS ARRAY_SIZE(formats)
|
|
|
|
|
2010-04-23 16:38:38 +08:00
|
|
|
/* Per-queue, driver-specific private data */
|
2014-09-22 20:27:17 +08:00
|
|
|
struct vim2m_q_data {
|
2010-04-23 16:38:38 +08:00
|
|
|
unsigned int width;
|
|
|
|
unsigned int height;
|
|
|
|
unsigned int sizeimage;
|
2014-03-10 21:58:28 +08:00
|
|
|
unsigned int sequence;
|
2014-09-22 20:27:17 +08:00
|
|
|
struct vim2m_fmt *fmt;
|
2010-04-23 16:38:38 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
V4L2_M2M_SRC = 0,
|
|
|
|
V4L2_M2M_DST = 1,
|
|
|
|
};
|
|
|
|
|
2012-07-18 21:35:37 +08:00
|
|
|
#define V4L2_CID_TRANS_TIME_MSEC (V4L2_CID_USER_BASE + 0x1000)
|
|
|
|
#define V4L2_CID_TRANS_NUM_BUFS (V4L2_CID_USER_BASE + 0x1001)
|
2010-04-23 16:38:38 +08:00
|
|
|
|
2019-02-27 05:03:45 +08:00
|
|
|
static struct vim2m_fmt *find_format(u32 fourcc)
|
2010-04-23 16:38:38 +08:00
|
|
|
{
|
2014-09-22 20:27:17 +08:00
|
|
|
struct vim2m_fmt *fmt;
|
2010-04-23 16:38:38 +08:00
|
|
|
unsigned int k;
|
|
|
|
|
|
|
|
for (k = 0; k < NUM_FORMATS; k++) {
|
|
|
|
fmt = &formats[k];
|
2019-02-27 05:03:45 +08:00
|
|
|
if (fmt->fourcc == fourcc)
|
2010-04-23 16:38:38 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (k == NUM_FORMATS)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return &formats[k];
|
|
|
|
}
|
|
|
|
|
2019-02-28 14:25:50 +08:00
|
|
|
static void get_alignment(u32 fourcc,
|
|
|
|
unsigned int *walign, unsigned int *halign)
|
|
|
|
{
|
|
|
|
switch (fourcc) {
|
|
|
|
case V4L2_PIX_FMT_SBGGR8:
|
|
|
|
case V4L2_PIX_FMT_SGBRG8:
|
|
|
|
case V4L2_PIX_FMT_SGRBG8:
|
|
|
|
case V4L2_PIX_FMT_SRGGB8:
|
|
|
|
*walign = BAYER_WIDTH_ALIGN;
|
|
|
|
*halign = BAYER_HEIGHT_ALIGN;
|
|
|
|
return;
|
|
|
|
default:
|
|
|
|
*walign = WIDTH_ALIGN;
|
|
|
|
*halign = HEIGHT_ALIGN;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-22 20:27:17 +08:00
|
|
|
struct vim2m_dev {
|
2010-04-23 16:38:38 +08:00
|
|
|
struct v4l2_device v4l2_dev;
|
2015-03-10 00:33:56 +08:00
|
|
|
struct video_device vfd;
|
2018-07-02 23:36:06 +08:00
|
|
|
#ifdef CONFIG_MEDIA_CONTROLLER
|
|
|
|
struct media_device mdev;
|
|
|
|
#endif
|
2010-04-23 16:38:38 +08:00
|
|
|
|
|
|
|
atomic_t num_inst;
|
|
|
|
struct mutex dev_mutex;
|
|
|
|
|
|
|
|
struct v4l2_m2m_dev *m2m_dev;
|
|
|
|
};
|
|
|
|
|
2014-09-22 20:27:17 +08:00
|
|
|
struct vim2m_ctx {
|
2012-07-18 21:35:37 +08:00
|
|
|
struct v4l2_fh fh;
|
2014-09-22 20:27:17 +08:00
|
|
|
struct vim2m_dev *dev;
|
2010-04-23 16:38:38 +08:00
|
|
|
|
2012-07-18 21:35:37 +08:00
|
|
|
struct v4l2_ctrl_handler hdl;
|
|
|
|
|
2010-04-23 16:38:38 +08:00
|
|
|
/* Processed buffers in this transaction */
|
|
|
|
u8 num_processed;
|
|
|
|
|
|
|
|
/* Transaction length (i.e. how many buffers per transaction) */
|
|
|
|
u32 translen;
|
|
|
|
/* Transaction time (i.e. simulated processing time) in milliseconds */
|
|
|
|
u32 transtime;
|
|
|
|
|
2019-01-30 00:00:16 +08:00
|
|
|
struct mutex vb_mutex;
|
|
|
|
struct delayed_work work_run;
|
|
|
|
|
2010-04-23 16:38:38 +08:00
|
|
|
/* Abort requested by m2m */
|
|
|
|
int aborting;
|
|
|
|
|
2012-06-12 17:43:49 +08:00
|
|
|
/* Processing mode */
|
|
|
|
int mode;
|
|
|
|
|
2012-07-18 22:33:22 +08:00
|
|
|
enum v4l2_colorspace colorspace;
|
2016-07-18 19:00:20 +08:00
|
|
|
enum v4l2_ycbcr_encoding ycbcr_enc;
|
|
|
|
enum v4l2_xfer_func xfer_func;
|
|
|
|
enum v4l2_quantization quant;
|
2012-07-18 22:33:22 +08:00
|
|
|
|
2012-06-08 15:47:34 +08:00
|
|
|
/* Source and destination queue data */
|
2014-09-22 20:27:17 +08:00
|
|
|
struct vim2m_q_data q_data[2];
|
2010-04-23 16:38:38 +08:00
|
|
|
};
|
|
|
|
|
2014-09-22 20:27:17 +08:00
|
|
|
static inline struct vim2m_ctx *file2ctx(struct file *file)
|
2012-07-18 21:35:37 +08:00
|
|
|
{
|
2014-09-22 20:27:17 +08:00
|
|
|
return container_of(file->private_data, struct vim2m_ctx, fh);
|
2012-07-18 21:35:37 +08:00
|
|
|
}
|
|
|
|
|
2014-09-22 20:27:17 +08:00
|
|
|
static struct vim2m_q_data *get_q_data(struct vim2m_ctx *ctx,
|
2019-03-02 00:45:04 +08:00
|
|
|
enum v4l2_buf_type type)
|
2012-06-08 15:47:34 +08:00
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case V4L2_BUF_TYPE_VIDEO_OUTPUT:
|
|
|
|
return &ctx->q_data[V4L2_M2M_SRC];
|
|
|
|
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
|
|
|
|
return &ctx->q_data[V4L2_M2M_DST];
|
|
|
|
default:
|
2019-03-02 00:46:11 +08:00
|
|
|
return NULL;
|
2012-06-08 15:47:34 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-26 20:29:57 +08:00
|
|
|
static const char *type_name(enum v4l2_buf_type type)
|
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case V4L2_BUF_TYPE_VIDEO_OUTPUT:
|
|
|
|
return "Output";
|
|
|
|
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
|
|
|
|
return "Capture";
|
|
|
|
default:
|
|
|
|
return "Invalid";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
media: vim2m: fix driver for it to handle different fourcc formats
Despite vim2m is reporting that it supports RGB565BE and YUYV,
that's not true.
Right now, it just says that it supports both format, but it
doesn't actually support them.
Also, horizontal flip is not properly implemented. It sounds
that it was designed to do a pseudo-horizontal flip using 8
tiles. Yet, as it doesn't do format conversion, the result
is a mess.
I suspect that it was done this way in order to save CPU time,
at the time of OMAP2 days.
That's messy and doesn't really help if someone wants to
use vim2m to test a pipeline.
Worse than that, the unique RGB format it says it supports is
RGB565BE, with is not supported by Gstreamer. That prevents
practical usage of it, even for tests.
So, instead, properly implement fourcc format conversions,
adding a few more RGB formats:
- RGB and BGR with 24 bits
- RGB565LE (known as RGB16 at gstreamer)
Also allows using any of the 5 supported formats as either
capture or output.
Note: The YUYV conversion routines are based on the conversion code
written by Hans de Goede inside libv4lconvert (part of v4l-utils),
released under LGPGL 2.1 (GPL 2.0 compatible).
Tested all possible format combinations except for RGB565BE,
as Gstreamer currently doesn't support it.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-01-30 00:00:15 +08:00
|
|
|
#define CLIP(__color) \
|
|
|
|
(u8)(((__color) > 0xff) ? 0xff : (((__color) < 0) ? 0 : (__color)))
|
2012-06-08 15:47:34 +08:00
|
|
|
|
2019-03-01 21:10:59 +08:00
|
|
|
static void copy_line(struct vim2m_q_data *q_data_out,
|
|
|
|
u8 *src, u8 *dst, bool reverse)
|
2010-04-23 16:38:38 +08:00
|
|
|
{
|
2019-03-01 21:10:59 +08:00
|
|
|
int x, depth = q_data_out->fmt->depth >> 3;
|
2010-04-23 16:38:38 +08:00
|
|
|
|
2019-02-26 19:36:00 +08:00
|
|
|
if (!reverse) {
|
2019-03-01 21:10:59 +08:00
|
|
|
memcpy(dst, src, q_data_out->width * depth);
|
|
|
|
} else {
|
|
|
|
for (x = 0; x < q_data_out->width >> 1; x++) {
|
|
|
|
memcpy(dst, src, depth);
|
|
|
|
memcpy(dst + depth, src - depth, depth);
|
|
|
|
src -= depth << 1;
|
|
|
|
dst += depth << 1;
|
|
|
|
}
|
2019-03-01 18:25:43 +08:00
|
|
|
return;
|
2019-02-26 19:36:00 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void copy_two_pixels(struct vim2m_q_data *q_data_in,
|
|
|
|
struct vim2m_q_data *q_data_out,
|
2019-03-01 19:14:52 +08:00
|
|
|
u8 *src[2], u8 **dst, int ypos, bool reverse)
|
2019-02-26 19:36:00 +08:00
|
|
|
{
|
|
|
|
struct vim2m_fmt *out = q_data_out->fmt;
|
|
|
|
struct vim2m_fmt *in = q_data_in->fmt;
|
|
|
|
u8 _r[2], _g[2], _b[2], *r, *g, *b;
|
2019-03-01 19:14:52 +08:00
|
|
|
int i;
|
2019-02-26 19:36:00 +08:00
|
|
|
|
media: vim2m: fix driver for it to handle different fourcc formats
Despite vim2m is reporting that it supports RGB565BE and YUYV,
that's not true.
Right now, it just says that it supports both format, but it
doesn't actually support them.
Also, horizontal flip is not properly implemented. It sounds
that it was designed to do a pseudo-horizontal flip using 8
tiles. Yet, as it doesn't do format conversion, the result
is a mess.
I suspect that it was done this way in order to save CPU time,
at the time of OMAP2 days.
That's messy and doesn't really help if someone wants to
use vim2m to test a pipeline.
Worse than that, the unique RGB format it says it supports is
RGB565BE, with is not supported by Gstreamer. That prevents
practical usage of it, even for tests.
So, instead, properly implement fourcc format conversions,
adding a few more RGB formats:
- RGB and BGR with 24 bits
- RGB565LE (known as RGB16 at gstreamer)
Also allows using any of the 5 supported formats as either
capture or output.
Note: The YUYV conversion routines are based on the conversion code
written by Hans de Goede inside libv4lconvert (part of v4l-utils),
released under LGPGL 2.1 (GPL 2.0 compatible).
Tested all possible format combinations except for RGB565BE,
as Gstreamer currently doesn't support it.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-01-30 00:00:15 +08:00
|
|
|
/* Step 1: read two consecutive pixels from src pointer */
|
2010-04-23 16:38:38 +08:00
|
|
|
|
media: vim2m: fix driver for it to handle different fourcc formats
Despite vim2m is reporting that it supports RGB565BE and YUYV,
that's not true.
Right now, it just says that it supports both format, but it
doesn't actually support them.
Also, horizontal flip is not properly implemented. It sounds
that it was designed to do a pseudo-horizontal flip using 8
tiles. Yet, as it doesn't do format conversion, the result
is a mess.
I suspect that it was done this way in order to save CPU time,
at the time of OMAP2 days.
That's messy and doesn't really help if someone wants to
use vim2m to test a pipeline.
Worse than that, the unique RGB format it says it supports is
RGB565BE, with is not supported by Gstreamer. That prevents
practical usage of it, even for tests.
So, instead, properly implement fourcc format conversions,
adding a few more RGB formats:
- RGB and BGR with 24 bits
- RGB565LE (known as RGB16 at gstreamer)
Also allows using any of the 5 supported formats as either
capture or output.
Note: The YUYV conversion routines are based on the conversion code
written by Hans de Goede inside libv4lconvert (part of v4l-utils),
released under LGPGL 2.1 (GPL 2.0 compatible).
Tested all possible format combinations except for RGB565BE,
as Gstreamer currently doesn't support it.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-01-30 00:00:15 +08:00
|
|
|
r = _r;
|
|
|
|
g = _g;
|
|
|
|
b = _b;
|
2013-04-17 14:04:10 +08:00
|
|
|
|
media: vim2m: fix driver for it to handle different fourcc formats
Despite vim2m is reporting that it supports RGB565BE and YUYV,
that's not true.
Right now, it just says that it supports both format, but it
doesn't actually support them.
Also, horizontal flip is not properly implemented. It sounds
that it was designed to do a pseudo-horizontal flip using 8
tiles. Yet, as it doesn't do format conversion, the result
is a mess.
I suspect that it was done this way in order to save CPU time,
at the time of OMAP2 days.
That's messy and doesn't really help if someone wants to
use vim2m to test a pipeline.
Worse than that, the unique RGB format it says it supports is
RGB565BE, with is not supported by Gstreamer. That prevents
practical usage of it, even for tests.
So, instead, properly implement fourcc format conversions,
adding a few more RGB formats:
- RGB and BGR with 24 bits
- RGB565LE (known as RGB16 at gstreamer)
Also allows using any of the 5 supported formats as either
capture or output.
Note: The YUYV conversion routines are based on the conversion code
written by Hans de Goede inside libv4lconvert (part of v4l-utils),
released under LGPGL 2.1 (GPL 2.0 compatible).
Tested all possible format combinations except for RGB565BE,
as Gstreamer currently doesn't support it.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-01-30 00:00:15 +08:00
|
|
|
switch (in->fourcc) {
|
|
|
|
case V4L2_PIX_FMT_RGB565: /* rrrrrggg gggbbbbb */
|
|
|
|
for (i = 0; i < 2; i++) {
|
2019-03-29 03:02:23 +08:00
|
|
|
u16 pix = le16_to_cpu(*(__le16 *)(src[i]));
|
media: vim2m: fix driver for it to handle different fourcc formats
Despite vim2m is reporting that it supports RGB565BE and YUYV,
that's not true.
Right now, it just says that it supports both format, but it
doesn't actually support them.
Also, horizontal flip is not properly implemented. It sounds
that it was designed to do a pseudo-horizontal flip using 8
tiles. Yet, as it doesn't do format conversion, the result
is a mess.
I suspect that it was done this way in order to save CPU time,
at the time of OMAP2 days.
That's messy and doesn't really help if someone wants to
use vim2m to test a pipeline.
Worse than that, the unique RGB format it says it supports is
RGB565BE, with is not supported by Gstreamer. That prevents
practical usage of it, even for tests.
So, instead, properly implement fourcc format conversions,
adding a few more RGB formats:
- RGB and BGR with 24 bits
- RGB565LE (known as RGB16 at gstreamer)
Also allows using any of the 5 supported formats as either
capture or output.
Note: The YUYV conversion routines are based on the conversion code
written by Hans de Goede inside libv4lconvert (part of v4l-utils),
released under LGPGL 2.1 (GPL 2.0 compatible).
Tested all possible format combinations except for RGB565BE,
as Gstreamer currently doesn't support it.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-01-30 00:00:15 +08:00
|
|
|
|
|
|
|
*r++ = (u8)(((pix & 0xf800) >> 11) << 3) | 0x07;
|
|
|
|
*g++ = (u8)((((pix & 0x07e0) >> 5)) << 2) | 0x03;
|
|
|
|
*b++ = (u8)((pix & 0x1f) << 3) | 0x07;
|
2012-06-12 17:43:49 +08:00
|
|
|
}
|
|
|
|
break;
|
media: vim2m: fix driver for it to handle different fourcc formats
Despite vim2m is reporting that it supports RGB565BE and YUYV,
that's not true.
Right now, it just says that it supports both format, but it
doesn't actually support them.
Also, horizontal flip is not properly implemented. It sounds
that it was designed to do a pseudo-horizontal flip using 8
tiles. Yet, as it doesn't do format conversion, the result
is a mess.
I suspect that it was done this way in order to save CPU time,
at the time of OMAP2 days.
That's messy and doesn't really help if someone wants to
use vim2m to test a pipeline.
Worse than that, the unique RGB format it says it supports is
RGB565BE, with is not supported by Gstreamer. That prevents
practical usage of it, even for tests.
So, instead, properly implement fourcc format conversions,
adding a few more RGB formats:
- RGB and BGR with 24 bits
- RGB565LE (known as RGB16 at gstreamer)
Also allows using any of the 5 supported formats as either
capture or output.
Note: The YUYV conversion routines are based on the conversion code
written by Hans de Goede inside libv4lconvert (part of v4l-utils),
released under LGPGL 2.1 (GPL 2.0 compatible).
Tested all possible format combinations except for RGB565BE,
as Gstreamer currently doesn't support it.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-01-30 00:00:15 +08:00
|
|
|
case V4L2_PIX_FMT_RGB565X: /* gggbbbbb rrrrrggg */
|
|
|
|
for (i = 0; i < 2; i++) {
|
2019-03-29 03:02:23 +08:00
|
|
|
u16 pix = be16_to_cpu(*(__be16 *)(src[i]));
|
2012-06-12 17:43:49 +08:00
|
|
|
|
2019-03-29 03:02:23 +08:00
|
|
|
*r++ = (u8)(((pix & 0xf800) >> 11) << 3) | 0x07;
|
|
|
|
*g++ = (u8)((((pix & 0x07e0) >> 5)) << 2) | 0x03;
|
|
|
|
*b++ = (u8)((pix & 0x1f) << 3) | 0x07;
|
2012-06-12 17:43:49 +08:00
|
|
|
}
|
|
|
|
break;
|
media: vim2m: don't accept YUYV anymore as output format
Handling any Y,Cr,Cb formats require some extra logic, as it
handles a group of two pixels. That's easy while we don't do
horizontal scaling.
However, doing horizontal scaling with such formats would require
a lot more code, in order to avoid distortions, as, if it scales
to two non-consecutive points, the logic would need to read 4
points in order to properly convert to RGB.
As this is just a test driver, and we want fast algorithms,
let's just get rid of this format as an output one.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-03-01 20:41:24 +08:00
|
|
|
default:
|
media: vim2m: fix driver for it to handle different fourcc formats
Despite vim2m is reporting that it supports RGB565BE and YUYV,
that's not true.
Right now, it just says that it supports both format, but it
doesn't actually support them.
Also, horizontal flip is not properly implemented. It sounds
that it was designed to do a pseudo-horizontal flip using 8
tiles. Yet, as it doesn't do format conversion, the result
is a mess.
I suspect that it was done this way in order to save CPU time,
at the time of OMAP2 days.
That's messy and doesn't really help if someone wants to
use vim2m to test a pipeline.
Worse than that, the unique RGB format it says it supports is
RGB565BE, with is not supported by Gstreamer. That prevents
practical usage of it, even for tests.
So, instead, properly implement fourcc format conversions,
adding a few more RGB formats:
- RGB and BGR with 24 bits
- RGB565LE (known as RGB16 at gstreamer)
Also allows using any of the 5 supported formats as either
capture or output.
Note: The YUYV conversion routines are based on the conversion code
written by Hans de Goede inside libv4lconvert (part of v4l-utils),
released under LGPGL 2.1 (GPL 2.0 compatible).
Tested all possible format combinations except for RGB565BE,
as Gstreamer currently doesn't support it.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-01-30 00:00:15 +08:00
|
|
|
case V4L2_PIX_FMT_RGB24:
|
|
|
|
for (i = 0; i < 2; i++) {
|
2019-03-01 19:14:52 +08:00
|
|
|
*r++ = src[i][0];
|
|
|
|
*g++ = src[i][1];
|
|
|
|
*b++ = src[i][2];
|
2012-06-12 17:43:49 +08:00
|
|
|
}
|
|
|
|
break;
|
media: vim2m: fix driver for it to handle different fourcc formats
Despite vim2m is reporting that it supports RGB565BE and YUYV,
that's not true.
Right now, it just says that it supports both format, but it
doesn't actually support them.
Also, horizontal flip is not properly implemented. It sounds
that it was designed to do a pseudo-horizontal flip using 8
tiles. Yet, as it doesn't do format conversion, the result
is a mess.
I suspect that it was done this way in order to save CPU time,
at the time of OMAP2 days.
That's messy and doesn't really help if someone wants to
use vim2m to test a pipeline.
Worse than that, the unique RGB format it says it supports is
RGB565BE, with is not supported by Gstreamer. That prevents
practical usage of it, even for tests.
So, instead, properly implement fourcc format conversions,
adding a few more RGB formats:
- RGB and BGR with 24 bits
- RGB565LE (known as RGB16 at gstreamer)
Also allows using any of the 5 supported formats as either
capture or output.
Note: The YUYV conversion routines are based on the conversion code
written by Hans de Goede inside libv4lconvert (part of v4l-utils),
released under LGPGL 2.1 (GPL 2.0 compatible).
Tested all possible format combinations except for RGB565BE,
as Gstreamer currently doesn't support it.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-01-30 00:00:15 +08:00
|
|
|
case V4L2_PIX_FMT_BGR24:
|
|
|
|
for (i = 0; i < 2; i++) {
|
2019-03-01 19:14:52 +08:00
|
|
|
*b++ = src[i][0];
|
|
|
|
*g++ = src[i][1];
|
|
|
|
*r++ = src[i][2];
|
media: vim2m: fix driver for it to handle different fourcc formats
Despite vim2m is reporting that it supports RGB565BE and YUYV,
that's not true.
Right now, it just says that it supports both format, but it
doesn't actually support them.
Also, horizontal flip is not properly implemented. It sounds
that it was designed to do a pseudo-horizontal flip using 8
tiles. Yet, as it doesn't do format conversion, the result
is a mess.
I suspect that it was done this way in order to save CPU time,
at the time of OMAP2 days.
That's messy and doesn't really help if someone wants to
use vim2m to test a pipeline.
Worse than that, the unique RGB format it says it supports is
RGB565BE, with is not supported by Gstreamer. That prevents
practical usage of it, even for tests.
So, instead, properly implement fourcc format conversions,
adding a few more RGB formats:
- RGB and BGR with 24 bits
- RGB565LE (known as RGB16 at gstreamer)
Also allows using any of the 5 supported formats as either
capture or output.
Note: The YUYV conversion routines are based on the conversion code
written by Hans de Goede inside libv4lconvert (part of v4l-utils),
released under LGPGL 2.1 (GPL 2.0 compatible).
Tested all possible format combinations except for RGB565BE,
as Gstreamer currently doesn't support it.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-01-30 00:00:15 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Step 2: store two consecutive points, reversing them if needed */
|
|
|
|
|
|
|
|
r = _r;
|
|
|
|
g = _g;
|
|
|
|
b = _b;
|
|
|
|
|
|
|
|
switch (out->fourcc) {
|
|
|
|
case V4L2_PIX_FMT_RGB565: /* rrrrrggg gggbbbbb */
|
|
|
|
for (i = 0; i < 2; i++) {
|
2019-03-29 03:02:23 +08:00
|
|
|
u16 pix;
|
|
|
|
__le16 *dst_pix = (__le16 *)*dst;
|
media: vim2m: fix driver for it to handle different fourcc formats
Despite vim2m is reporting that it supports RGB565BE and YUYV,
that's not true.
Right now, it just says that it supports both format, but it
doesn't actually support them.
Also, horizontal flip is not properly implemented. It sounds
that it was designed to do a pseudo-horizontal flip using 8
tiles. Yet, as it doesn't do format conversion, the result
is a mess.
I suspect that it was done this way in order to save CPU time,
at the time of OMAP2 days.
That's messy and doesn't really help if someone wants to
use vim2m to test a pipeline.
Worse than that, the unique RGB format it says it supports is
RGB565BE, with is not supported by Gstreamer. That prevents
practical usage of it, even for tests.
So, instead, properly implement fourcc format conversions,
adding a few more RGB formats:
- RGB and BGR with 24 bits
- RGB565LE (known as RGB16 at gstreamer)
Also allows using any of the 5 supported formats as either
capture or output.
Note: The YUYV conversion routines are based on the conversion code
written by Hans de Goede inside libv4lconvert (part of v4l-utils),
released under LGPGL 2.1 (GPL 2.0 compatible).
Tested all possible format combinations except for RGB565BE,
as Gstreamer currently doesn't support it.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-01-30 00:00:15 +08:00
|
|
|
|
2019-03-29 03:02:23 +08:00
|
|
|
pix = ((*r << 8) & 0xf800) | ((*g << 3) & 0x07e0) |
|
|
|
|
(*b >> 3);
|
|
|
|
|
|
|
|
*dst_pix = cpu_to_le16(pix);
|
media: vim2m: fix driver for it to handle different fourcc formats
Despite vim2m is reporting that it supports RGB565BE and YUYV,
that's not true.
Right now, it just says that it supports both format, but it
doesn't actually support them.
Also, horizontal flip is not properly implemented. It sounds
that it was designed to do a pseudo-horizontal flip using 8
tiles. Yet, as it doesn't do format conversion, the result
is a mess.
I suspect that it was done this way in order to save CPU time,
at the time of OMAP2 days.
That's messy and doesn't really help if someone wants to
use vim2m to test a pipeline.
Worse than that, the unique RGB format it says it supports is
RGB565BE, with is not supported by Gstreamer. That prevents
practical usage of it, even for tests.
So, instead, properly implement fourcc format conversions,
adding a few more RGB formats:
- RGB and BGR with 24 bits
- RGB565LE (known as RGB16 at gstreamer)
Also allows using any of the 5 supported formats as either
capture or output.
Note: The YUYV conversion routines are based on the conversion code
written by Hans de Goede inside libv4lconvert (part of v4l-utils),
released under LGPGL 2.1 (GPL 2.0 compatible).
Tested all possible format combinations except for RGB565BE,
as Gstreamer currently doesn't support it.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-01-30 00:00:15 +08:00
|
|
|
|
|
|
|
*dst += 2;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
case V4L2_PIX_FMT_RGB565X: /* gggbbbbb rrrrrggg */
|
|
|
|
for (i = 0; i < 2; i++) {
|
2019-03-29 03:02:23 +08:00
|
|
|
u16 pix;
|
|
|
|
__be16 *dst_pix = (__be16 *)*dst;
|
|
|
|
|
|
|
|
pix = ((*r << 8) & 0xf800) | ((*g << 3) & 0x07e0) |
|
|
|
|
(*b >> 3);
|
media: vim2m: fix driver for it to handle different fourcc formats
Despite vim2m is reporting that it supports RGB565BE and YUYV,
that's not true.
Right now, it just says that it supports both format, but it
doesn't actually support them.
Also, horizontal flip is not properly implemented. It sounds
that it was designed to do a pseudo-horizontal flip using 8
tiles. Yet, as it doesn't do format conversion, the result
is a mess.
I suspect that it was done this way in order to save CPU time,
at the time of OMAP2 days.
That's messy and doesn't really help if someone wants to
use vim2m to test a pipeline.
Worse than that, the unique RGB format it says it supports is
RGB565BE, with is not supported by Gstreamer. That prevents
practical usage of it, even for tests.
So, instead, properly implement fourcc format conversions,
adding a few more RGB formats:
- RGB and BGR with 24 bits
- RGB565LE (known as RGB16 at gstreamer)
Also allows using any of the 5 supported formats as either
capture or output.
Note: The YUYV conversion routines are based on the conversion code
written by Hans de Goede inside libv4lconvert (part of v4l-utils),
released under LGPGL 2.1 (GPL 2.0 compatible).
Tested all possible format combinations except for RGB565BE,
as Gstreamer currently doesn't support it.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-01-30 00:00:15 +08:00
|
|
|
|
2019-03-29 03:02:23 +08:00
|
|
|
*dst_pix = cpu_to_be16(pix);
|
media: vim2m: fix driver for it to handle different fourcc formats
Despite vim2m is reporting that it supports RGB565BE and YUYV,
that's not true.
Right now, it just says that it supports both format, but it
doesn't actually support them.
Also, horizontal flip is not properly implemented. It sounds
that it was designed to do a pseudo-horizontal flip using 8
tiles. Yet, as it doesn't do format conversion, the result
is a mess.
I suspect that it was done this way in order to save CPU time,
at the time of OMAP2 days.
That's messy and doesn't really help if someone wants to
use vim2m to test a pipeline.
Worse than that, the unique RGB format it says it supports is
RGB565BE, with is not supported by Gstreamer. That prevents
practical usage of it, even for tests.
So, instead, properly implement fourcc format conversions,
adding a few more RGB formats:
- RGB and BGR with 24 bits
- RGB565LE (known as RGB16 at gstreamer)
Also allows using any of the 5 supported formats as either
capture or output.
Note: The YUYV conversion routines are based on the conversion code
written by Hans de Goede inside libv4lconvert (part of v4l-utils),
released under LGPGL 2.1 (GPL 2.0 compatible).
Tested all possible format combinations except for RGB565BE,
as Gstreamer currently doesn't support it.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-01-30 00:00:15 +08:00
|
|
|
|
|
|
|
*dst += 2;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
case V4L2_PIX_FMT_RGB24:
|
|
|
|
for (i = 0; i < 2; i++) {
|
|
|
|
*(*dst)++ = *r++;
|
|
|
|
*(*dst)++ = *g++;
|
|
|
|
*(*dst)++ = *b++;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
case V4L2_PIX_FMT_BGR24:
|
|
|
|
for (i = 0; i < 2; i++) {
|
|
|
|
*(*dst)++ = *b++;
|
|
|
|
*(*dst)++ = *g++;
|
|
|
|
*(*dst)++ = *r++;
|
|
|
|
}
|
|
|
|
return;
|
2019-02-01 20:58:46 +08:00
|
|
|
case V4L2_PIX_FMT_YUYV:
|
|
|
|
default:
|
media: vim2m: fix driver for it to handle different fourcc formats
Despite vim2m is reporting that it supports RGB565BE and YUYV,
that's not true.
Right now, it just says that it supports both format, but it
doesn't actually support them.
Also, horizontal flip is not properly implemented. It sounds
that it was designed to do a pseudo-horizontal flip using 8
tiles. Yet, as it doesn't do format conversion, the result
is a mess.
I suspect that it was done this way in order to save CPU time,
at the time of OMAP2 days.
That's messy and doesn't really help if someone wants to
use vim2m to test a pipeline.
Worse than that, the unique RGB format it says it supports is
RGB565BE, with is not supported by Gstreamer. That prevents
practical usage of it, even for tests.
So, instead, properly implement fourcc format conversions,
adding a few more RGB formats:
- RGB and BGR with 24 bits
- RGB565LE (known as RGB16 at gstreamer)
Also allows using any of the 5 supported formats as either
capture or output.
Note: The YUYV conversion routines are based on the conversion code
written by Hans de Goede inside libv4lconvert (part of v4l-utils),
released under LGPGL 2.1 (GPL 2.0 compatible).
Tested all possible format combinations except for RGB565BE,
as Gstreamer currently doesn't support it.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-01-30 00:00:15 +08:00
|
|
|
{
|
|
|
|
u8 y, y1, u, v;
|
|
|
|
|
|
|
|
y = ((8453 * (*r) + 16594 * (*g) + 3223 * (*b)
|
|
|
|
+ 524288) >> 15);
|
|
|
|
u = ((-4878 * (*r) - 9578 * (*g) + 14456 * (*b)
|
|
|
|
+ 4210688) >> 15);
|
|
|
|
v = ((14456 * (*r++) - 12105 * (*g++) - 2351 * (*b++)
|
|
|
|
+ 4210688) >> 15);
|
|
|
|
y1 = ((8453 * (*r) + 16594 * (*g) + 3223 * (*b)
|
|
|
|
+ 524288) >> 15);
|
|
|
|
|
|
|
|
*(*dst)++ = y;
|
|
|
|
*(*dst)++ = u;
|
|
|
|
|
|
|
|
*(*dst)++ = y1;
|
|
|
|
*(*dst)++ = v;
|
|
|
|
return;
|
|
|
|
}
|
2019-02-01 20:58:46 +08:00
|
|
|
case V4L2_PIX_FMT_SBGGR8:
|
|
|
|
if (!(ypos & 1)) {
|
|
|
|
*(*dst)++ = *b;
|
|
|
|
*(*dst)++ = *++g;
|
|
|
|
} else {
|
|
|
|
*(*dst)++ = *g;
|
|
|
|
*(*dst)++ = *++r;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
case V4L2_PIX_FMT_SGBRG8:
|
|
|
|
if (!(ypos & 1)) {
|
|
|
|
*(*dst)++ = *g;
|
|
|
|
*(*dst)++ = *++b;
|
|
|
|
} else {
|
|
|
|
*(*dst)++ = *r;
|
|
|
|
*(*dst)++ = *++g;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
case V4L2_PIX_FMT_SGRBG8:
|
|
|
|
if (!(ypos & 1)) {
|
|
|
|
*(*dst)++ = *g;
|
|
|
|
*(*dst)++ = *++r;
|
|
|
|
} else {
|
|
|
|
*(*dst)++ = *b;
|
|
|
|
*(*dst)++ = *++g;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
case V4L2_PIX_FMT_SRGGB8:
|
|
|
|
if (!(ypos & 1)) {
|
|
|
|
*(*dst)++ = *r;
|
|
|
|
*(*dst)++ = *++g;
|
|
|
|
} else {
|
|
|
|
*(*dst)++ = *g;
|
|
|
|
*(*dst)++ = *++b;
|
|
|
|
}
|
|
|
|
return;
|
media: vim2m: fix driver for it to handle different fourcc formats
Despite vim2m is reporting that it supports RGB565BE and YUYV,
that's not true.
Right now, it just says that it supports both format, but it
doesn't actually support them.
Also, horizontal flip is not properly implemented. It sounds
that it was designed to do a pseudo-horizontal flip using 8
tiles. Yet, as it doesn't do format conversion, the result
is a mess.
I suspect that it was done this way in order to save CPU time,
at the time of OMAP2 days.
That's messy and doesn't really help if someone wants to
use vim2m to test a pipeline.
Worse than that, the unique RGB format it says it supports is
RGB565BE, with is not supported by Gstreamer. That prevents
practical usage of it, even for tests.
So, instead, properly implement fourcc format conversions,
adding a few more RGB formats:
- RGB and BGR with 24 bits
- RGB565LE (known as RGB16 at gstreamer)
Also allows using any of the 5 supported formats as either
capture or output.
Note: The YUYV conversion routines are based on the conversion code
written by Hans de Goede inside libv4lconvert (part of v4l-utils),
released under LGPGL 2.1 (GPL 2.0 compatible).
Tested all possible format combinations except for RGB565BE,
as Gstreamer currently doesn't support it.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-01-30 00:00:15 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int device_process(struct vim2m_ctx *ctx,
|
|
|
|
struct vb2_v4l2_buffer *in_vb,
|
|
|
|
struct vb2_v4l2_buffer *out_vb)
|
|
|
|
{
|
|
|
|
struct vim2m_dev *dev = ctx->dev;
|
|
|
|
struct vim2m_q_data *q_data_in, *q_data_out;
|
2019-03-01 19:14:52 +08:00
|
|
|
u8 *p_in, *p_line, *p_in_x[2], *p, *p_out;
|
|
|
|
unsigned int width, height, bytesperline, bytes_per_pixel;
|
|
|
|
unsigned int x, y, y_in, y_out, x_int, x_fract, x_err, x_offset;
|
2019-02-26 19:36:00 +08:00
|
|
|
int start, end, step;
|
media: vim2m: fix driver for it to handle different fourcc formats
Despite vim2m is reporting that it supports RGB565BE and YUYV,
that's not true.
Right now, it just says that it supports both format, but it
doesn't actually support them.
Also, horizontal flip is not properly implemented. It sounds
that it was designed to do a pseudo-horizontal flip using 8
tiles. Yet, as it doesn't do format conversion, the result
is a mess.
I suspect that it was done this way in order to save CPU time,
at the time of OMAP2 days.
That's messy and doesn't really help if someone wants to
use vim2m to test a pipeline.
Worse than that, the unique RGB format it says it supports is
RGB565BE, with is not supported by Gstreamer. That prevents
practical usage of it, even for tests.
So, instead, properly implement fourcc format conversions,
adding a few more RGB formats:
- RGB and BGR with 24 bits
- RGB565LE (known as RGB16 at gstreamer)
Also allows using any of the 5 supported formats as either
capture or output.
Note: The YUYV conversion routines are based on the conversion code
written by Hans de Goede inside libv4lconvert (part of v4l-utils),
released under LGPGL 2.1 (GPL 2.0 compatible).
Tested all possible format combinations except for RGB565BE,
as Gstreamer currently doesn't support it.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-01-30 00:00:15 +08:00
|
|
|
|
|
|
|
q_data_in = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT);
|
2019-03-02 00:46:11 +08:00
|
|
|
if (!q_data_in)
|
|
|
|
return 0;
|
media: vim2m: fix driver for it to handle different fourcc formats
Despite vim2m is reporting that it supports RGB565BE and YUYV,
that's not true.
Right now, it just says that it supports both format, but it
doesn't actually support them.
Also, horizontal flip is not properly implemented. It sounds
that it was designed to do a pseudo-horizontal flip using 8
tiles. Yet, as it doesn't do format conversion, the result
is a mess.
I suspect that it was done this way in order to save CPU time,
at the time of OMAP2 days.
That's messy and doesn't really help if someone wants to
use vim2m to test a pipeline.
Worse than that, the unique RGB format it says it supports is
RGB565BE, with is not supported by Gstreamer. That prevents
practical usage of it, even for tests.
So, instead, properly implement fourcc format conversions,
adding a few more RGB formats:
- RGB and BGR with 24 bits
- RGB565LE (known as RGB16 at gstreamer)
Also allows using any of the 5 supported formats as either
capture or output.
Note: The YUYV conversion routines are based on the conversion code
written by Hans de Goede inside libv4lconvert (part of v4l-utils),
released under LGPGL 2.1 (GPL 2.0 compatible).
Tested all possible format combinations except for RGB565BE,
as Gstreamer currently doesn't support it.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-01-30 00:00:15 +08:00
|
|
|
bytesperline = (q_data_in->width * q_data_in->fmt->depth) >> 3;
|
2019-03-01 19:14:52 +08:00
|
|
|
bytes_per_pixel = q_data_in->fmt->depth >> 3;
|
media: vim2m: fix driver for it to handle different fourcc formats
Despite vim2m is reporting that it supports RGB565BE and YUYV,
that's not true.
Right now, it just says that it supports both format, but it
doesn't actually support them.
Also, horizontal flip is not properly implemented. It sounds
that it was designed to do a pseudo-horizontal flip using 8
tiles. Yet, as it doesn't do format conversion, the result
is a mess.
I suspect that it was done this way in order to save CPU time,
at the time of OMAP2 days.
That's messy and doesn't really help if someone wants to
use vim2m to test a pipeline.
Worse than that, the unique RGB format it says it supports is
RGB565BE, with is not supported by Gstreamer. That prevents
practical usage of it, even for tests.
So, instead, properly implement fourcc format conversions,
adding a few more RGB formats:
- RGB and BGR with 24 bits
- RGB565LE (known as RGB16 at gstreamer)
Also allows using any of the 5 supported formats as either
capture or output.
Note: The YUYV conversion routines are based on the conversion code
written by Hans de Goede inside libv4lconvert (part of v4l-utils),
released under LGPGL 2.1 (GPL 2.0 compatible).
Tested all possible format combinations except for RGB565BE,
as Gstreamer currently doesn't support it.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-01-30 00:00:15 +08:00
|
|
|
|
|
|
|
q_data_out = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE);
|
2019-03-02 00:46:11 +08:00
|
|
|
if (!q_data_out)
|
|
|
|
return 0;
|
2019-02-26 19:36:00 +08:00
|
|
|
|
2019-03-01 19:14:52 +08:00
|
|
|
/* As we're doing scaling, use the output dimensions here */
|
2019-03-01 18:25:43 +08:00
|
|
|
height = q_data_out->height;
|
2019-03-01 19:14:52 +08:00
|
|
|
width = q_data_out->width;
|
media: vim2m: fix driver for it to handle different fourcc formats
Despite vim2m is reporting that it supports RGB565BE and YUYV,
that's not true.
Right now, it just says that it supports both format, but it
doesn't actually support them.
Also, horizontal flip is not properly implemented. It sounds
that it was designed to do a pseudo-horizontal flip using 8
tiles. Yet, as it doesn't do format conversion, the result
is a mess.
I suspect that it was done this way in order to save CPU time,
at the time of OMAP2 days.
That's messy and doesn't really help if someone wants to
use vim2m to test a pipeline.
Worse than that, the unique RGB format it says it supports is
RGB565BE, with is not supported by Gstreamer. That prevents
practical usage of it, even for tests.
So, instead, properly implement fourcc format conversions,
adding a few more RGB formats:
- RGB and BGR with 24 bits
- RGB565LE (known as RGB16 at gstreamer)
Also allows using any of the 5 supported formats as either
capture or output.
Note: The YUYV conversion routines are based on the conversion code
written by Hans de Goede inside libv4lconvert (part of v4l-utils),
released under LGPGL 2.1 (GPL 2.0 compatible).
Tested all possible format combinations except for RGB565BE,
as Gstreamer currently doesn't support it.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-01-30 00:00:15 +08:00
|
|
|
|
|
|
|
p_in = vb2_plane_vaddr(&in_vb->vb2_buf, 0);
|
|
|
|
p_out = vb2_plane_vaddr(&out_vb->vb2_buf, 0);
|
|
|
|
if (!p_in || !p_out) {
|
|
|
|
v4l2_err(&dev->v4l2_dev,
|
|
|
|
"Acquiring kernel pointers to buffers failed\n");
|
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
|
2019-03-02 00:46:11 +08:00
|
|
|
out_vb->sequence = q_data_out->sequence++;
|
media: vim2m: fix driver for it to handle different fourcc formats
Despite vim2m is reporting that it supports RGB565BE and YUYV,
that's not true.
Right now, it just says that it supports both format, but it
doesn't actually support them.
Also, horizontal flip is not properly implemented. It sounds
that it was designed to do a pseudo-horizontal flip using 8
tiles. Yet, as it doesn't do format conversion, the result
is a mess.
I suspect that it was done this way in order to save CPU time,
at the time of OMAP2 days.
That's messy and doesn't really help if someone wants to
use vim2m to test a pipeline.
Worse than that, the unique RGB format it says it supports is
RGB565BE, with is not supported by Gstreamer. That prevents
practical usage of it, even for tests.
So, instead, properly implement fourcc format conversions,
adding a few more RGB formats:
- RGB and BGR with 24 bits
- RGB565LE (known as RGB16 at gstreamer)
Also allows using any of the 5 supported formats as either
capture or output.
Note: The YUYV conversion routines are based on the conversion code
written by Hans de Goede inside libv4lconvert (part of v4l-utils),
released under LGPGL 2.1 (GPL 2.0 compatible).
Tested all possible format combinations except for RGB565BE,
as Gstreamer currently doesn't support it.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-01-30 00:00:15 +08:00
|
|
|
in_vb->sequence = q_data_in->sequence++;
|
2019-02-06 05:20:33 +08:00
|
|
|
v4l2_m2m_buf_copy_metadata(in_vb, out_vb, true);
|
media: vim2m: fix driver for it to handle different fourcc formats
Despite vim2m is reporting that it supports RGB565BE and YUYV,
that's not true.
Right now, it just says that it supports both format, but it
doesn't actually support them.
Also, horizontal flip is not properly implemented. It sounds
that it was designed to do a pseudo-horizontal flip using 8
tiles. Yet, as it doesn't do format conversion, the result
is a mess.
I suspect that it was done this way in order to save CPU time,
at the time of OMAP2 days.
That's messy and doesn't really help if someone wants to
use vim2m to test a pipeline.
Worse than that, the unique RGB format it says it supports is
RGB565BE, with is not supported by Gstreamer. That prevents
practical usage of it, even for tests.
So, instead, properly implement fourcc format conversions,
adding a few more RGB formats:
- RGB and BGR with 24 bits
- RGB565LE (known as RGB16 at gstreamer)
Also allows using any of the 5 supported formats as either
capture or output.
Note: The YUYV conversion routines are based on the conversion code
written by Hans de Goede inside libv4lconvert (part of v4l-utils),
released under LGPGL 2.1 (GPL 2.0 compatible).
Tested all possible format combinations except for RGB565BE,
as Gstreamer currently doesn't support it.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-01-30 00:00:15 +08:00
|
|
|
|
|
|
|
if (ctx->mode & MEM2MEM_VFLIP) {
|
|
|
|
start = height - 1;
|
|
|
|
end = -1;
|
|
|
|
step = -1;
|
|
|
|
} else {
|
|
|
|
start = 0;
|
|
|
|
end = height;
|
|
|
|
step = 1;
|
|
|
|
}
|
2019-02-01 20:58:46 +08:00
|
|
|
y_out = 0;
|
2019-03-01 18:25:43 +08:00
|
|
|
|
2019-03-02 00:45:04 +08:00
|
|
|
/*
|
|
|
|
* When format and resolution are identical,
|
|
|
|
* we can use a faster copy logic
|
|
|
|
*/
|
2019-03-01 18:25:43 +08:00
|
|
|
if (q_data_in->fmt->fourcc == q_data_out->fmt->fourcc &&
|
|
|
|
q_data_in->width == q_data_out->width &&
|
|
|
|
q_data_in->height == q_data_out->height) {
|
|
|
|
for (y = start; y != end; y += step, y_out++) {
|
|
|
|
p = p_in + (y * bytesperline);
|
|
|
|
if (ctx->mode & MEM2MEM_HFLIP)
|
|
|
|
p += bytesperline - (q_data_in->fmt->depth >> 3);
|
|
|
|
|
2019-03-01 21:10:59 +08:00
|
|
|
copy_line(q_data_out, p, p_out,
|
|
|
|
ctx->mode & MEM2MEM_HFLIP);
|
|
|
|
|
|
|
|
p_out += bytesperline;
|
2019-03-01 18:25:43 +08:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-03-01 21:10:59 +08:00
|
|
|
/* Slower algorithm with format conversion, hflip, vflip and scaler */
|
2019-03-01 19:14:52 +08:00
|
|
|
|
|
|
|
/* To speed scaler up, use Bresenham for X dimension */
|
|
|
|
x_int = q_data_in->width / q_data_out->width;
|
|
|
|
x_fract = q_data_in->width % q_data_out->width;
|
|
|
|
|
2019-02-01 20:58:46 +08:00
|
|
|
for (y = start; y != end; y += step, y_out++) {
|
2019-03-01 18:25:43 +08:00
|
|
|
y_in = (y * q_data_in->height) / q_data_out->height;
|
2019-03-01 19:14:52 +08:00
|
|
|
x_offset = 0;
|
|
|
|
x_err = 0;
|
2019-03-01 18:25:43 +08:00
|
|
|
|
2019-03-01 19:14:52 +08:00
|
|
|
p_line = p_in + (y_in * bytesperline);
|
media: vim2m: fix driver for it to handle different fourcc formats
Despite vim2m is reporting that it supports RGB565BE and YUYV,
that's not true.
Right now, it just says that it supports both format, but it
doesn't actually support them.
Also, horizontal flip is not properly implemented. It sounds
that it was designed to do a pseudo-horizontal flip using 8
tiles. Yet, as it doesn't do format conversion, the result
is a mess.
I suspect that it was done this way in order to save CPU time,
at the time of OMAP2 days.
That's messy and doesn't really help if someone wants to
use vim2m to test a pipeline.
Worse than that, the unique RGB format it says it supports is
RGB565BE, with is not supported by Gstreamer. That prevents
practical usage of it, even for tests.
So, instead, properly implement fourcc format conversions,
adding a few more RGB formats:
- RGB and BGR with 24 bits
- RGB565LE (known as RGB16 at gstreamer)
Also allows using any of the 5 supported formats as either
capture or output.
Note: The YUYV conversion routines are based on the conversion code
written by Hans de Goede inside libv4lconvert (part of v4l-utils),
released under LGPGL 2.1 (GPL 2.0 compatible).
Tested all possible format combinations except for RGB565BE,
as Gstreamer currently doesn't support it.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-01-30 00:00:15 +08:00
|
|
|
if (ctx->mode & MEM2MEM_HFLIP)
|
2019-03-01 19:14:52 +08:00
|
|
|
p_line += bytesperline - (q_data_in->fmt->depth >> 3);
|
|
|
|
p_in_x[0] = p_line;
|
|
|
|
|
|
|
|
for (x = 0; x < width >> 1; x++) {
|
|
|
|
x_offset += x_int;
|
|
|
|
x_err += x_fract;
|
|
|
|
if (x_err > width) {
|
|
|
|
x_offset++;
|
|
|
|
x_err -= width;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ctx->mode & MEM2MEM_HFLIP)
|
|
|
|
p_in_x[1] = p_line - x_offset * bytes_per_pixel;
|
|
|
|
else
|
|
|
|
p_in_x[1] = p_line + x_offset * bytes_per_pixel;
|
media: vim2m: fix driver for it to handle different fourcc formats
Despite vim2m is reporting that it supports RGB565BE and YUYV,
that's not true.
Right now, it just says that it supports both format, but it
doesn't actually support them.
Also, horizontal flip is not properly implemented. It sounds
that it was designed to do a pseudo-horizontal flip using 8
tiles. Yet, as it doesn't do format conversion, the result
is a mess.
I suspect that it was done this way in order to save CPU time,
at the time of OMAP2 days.
That's messy and doesn't really help if someone wants to
use vim2m to test a pipeline.
Worse than that, the unique RGB format it says it supports is
RGB565BE, with is not supported by Gstreamer. That prevents
practical usage of it, even for tests.
So, instead, properly implement fourcc format conversions,
adding a few more RGB formats:
- RGB and BGR with 24 bits
- RGB565LE (known as RGB16 at gstreamer)
Also allows using any of the 5 supported formats as either
capture or output.
Note: The YUYV conversion routines are based on the conversion code
written by Hans de Goede inside libv4lconvert (part of v4l-utils),
released under LGPGL 2.1 (GPL 2.0 compatible).
Tested all possible format combinations except for RGB565BE,
as Gstreamer currently doesn't support it.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-01-30 00:00:15 +08:00
|
|
|
|
2019-03-01 19:14:52 +08:00
|
|
|
copy_two_pixels(q_data_in, q_data_out,
|
|
|
|
p_in_x, &p_out, y_out,
|
media: vim2m: fix driver for it to handle different fourcc formats
Despite vim2m is reporting that it supports RGB565BE and YUYV,
that's not true.
Right now, it just says that it supports both format, but it
doesn't actually support them.
Also, horizontal flip is not properly implemented. It sounds
that it was designed to do a pseudo-horizontal flip using 8
tiles. Yet, as it doesn't do format conversion, the result
is a mess.
I suspect that it was done this way in order to save CPU time,
at the time of OMAP2 days.
That's messy and doesn't really help if someone wants to
use vim2m to test a pipeline.
Worse than that, the unique RGB format it says it supports is
RGB565BE, with is not supported by Gstreamer. That prevents
practical usage of it, even for tests.
So, instead, properly implement fourcc format conversions,
adding a few more RGB formats:
- RGB and BGR with 24 bits
- RGB565LE (known as RGB16 at gstreamer)
Also allows using any of the 5 supported formats as either
capture or output.
Note: The YUYV conversion routines are based on the conversion code
written by Hans de Goede inside libv4lconvert (part of v4l-utils),
released under LGPGL 2.1 (GPL 2.0 compatible).
Tested all possible format combinations except for RGB565BE,
as Gstreamer currently doesn't support it.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-01-30 00:00:15 +08:00
|
|
|
ctx->mode & MEM2MEM_HFLIP);
|
2019-02-26 19:36:00 +08:00
|
|
|
|
2019-03-01 19:14:52 +08:00
|
|
|
/* Calculate the next p_in_x0 */
|
|
|
|
x_offset += x_int;
|
|
|
|
x_err += x_fract;
|
|
|
|
if (x_err > width) {
|
|
|
|
x_offset++;
|
|
|
|
x_err -= width;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ctx->mode & MEM2MEM_HFLIP)
|
|
|
|
p_in_x[0] = p_line - x_offset * bytes_per_pixel;
|
|
|
|
else
|
|
|
|
p_in_x[0] = p_line + x_offset * bytes_per_pixel;
|
|
|
|
}
|
2010-04-23 16:38:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* mem2mem callbacks
|
|
|
|
*/
|
|
|
|
|
2017-11-29 21:33:45 +08:00
|
|
|
/*
|
2010-04-23 16:38:38 +08:00
|
|
|
* job_ready() - check whether an instance is ready to be scheduled to run
|
|
|
|
*/
|
|
|
|
static int job_ready(void *priv)
|
|
|
|
{
|
2014-09-22 20:27:17 +08:00
|
|
|
struct vim2m_ctx *ctx = priv;
|
2010-04-23 16:38:38 +08:00
|
|
|
|
2013-08-26 04:27:45 +08:00
|
|
|
if (v4l2_m2m_num_src_bufs_ready(ctx->fh.m2m_ctx) < ctx->translen
|
|
|
|
|| v4l2_m2m_num_dst_bufs_ready(ctx->fh.m2m_ctx) < ctx->translen) {
|
2019-02-26 20:29:57 +08:00
|
|
|
dprintk(ctx->dev, 1, "Not enough buffers available\n");
|
2010-04-23 16:38:38 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void job_abort(void *priv)
|
|
|
|
{
|
2014-09-22 20:27:17 +08:00
|
|
|
struct vim2m_ctx *ctx = priv;
|
2010-04-23 16:38:38 +08:00
|
|
|
|
|
|
|
/* Will cancel the transaction in the next interrupt handler */
|
|
|
|
ctx->aborting = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* device_run() - prepares and starts the device
|
|
|
|
*
|
|
|
|
* This simulates all the immediate preparations required before starting
|
|
|
|
* a device. This will be called by the framework when it decides to schedule
|
|
|
|
* a particular instance.
|
|
|
|
*/
|
|
|
|
static void device_run(void *priv)
|
|
|
|
{
|
2014-09-22 20:27:17 +08:00
|
|
|
struct vim2m_ctx *ctx = priv;
|
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 21:30:30 +08:00
|
|
|
struct vb2_v4l2_buffer *src_buf, *dst_buf;
|
2010-04-23 16:38:38 +08:00
|
|
|
|
2013-08-26 04:27:45 +08:00
|
|
|
src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
|
|
|
|
dst_buf = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx);
|
2010-04-23 16:38:38 +08:00
|
|
|
|
2018-05-21 16:54:57 +08:00
|
|
|
/* Apply request controls if any */
|
|
|
|
v4l2_ctrl_request_setup(src_buf->vb2_buf.req_obj.req,
|
|
|
|
&ctx->hdl);
|
|
|
|
|
2010-04-23 16:38:38 +08:00
|
|
|
device_process(ctx, src_buf, dst_buf);
|
|
|
|
|
2018-05-21 16:54:57 +08:00
|
|
|
/* Complete request controls if any */
|
|
|
|
v4l2_ctrl_request_complete(src_buf->vb2_buf.req_obj.req,
|
|
|
|
&ctx->hdl);
|
|
|
|
|
2018-05-21 16:54:56 +08:00
|
|
|
/* Run delayed work, which simulates a hardware irq */
|
2019-01-30 00:00:16 +08:00
|
|
|
schedule_delayed_work(&ctx->work_run, msecs_to_jiffies(ctx->transtime));
|
2010-04-23 16:38:38 +08:00
|
|
|
}
|
|
|
|
|
2018-05-21 16:54:56 +08:00
|
|
|
static void device_work(struct work_struct *w)
|
2010-04-23 16:38:38 +08:00
|
|
|
{
|
2014-09-22 20:27:17 +08:00
|
|
|
struct vim2m_ctx *curr_ctx;
|
2019-01-30 00:00:16 +08:00
|
|
|
struct vim2m_dev *vim2m_dev;
|
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 21:30:30 +08:00
|
|
|
struct vb2_v4l2_buffer *src_vb, *dst_vb;
|
2010-04-23 16:38:38 +08:00
|
|
|
|
2019-01-30 00:00:16 +08:00
|
|
|
curr_ctx = container_of(w, struct vim2m_ctx, work_run.work);
|
2010-04-23 16:38:38 +08:00
|
|
|
|
2019-03-02 00:45:04 +08:00
|
|
|
if (!curr_ctx) {
|
2012-09-24 13:17:47 +08:00
|
|
|
pr_err("Instance released before the end of transaction\n");
|
2010-04-23 16:38:38 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-02-08 01:28:19 +08:00
|
|
|
vim2m_dev = curr_ctx->dev;
|
|
|
|
|
2013-08-26 04:27:45 +08:00
|
|
|
src_vb = v4l2_m2m_src_buf_remove(curr_ctx->fh.m2m_ctx);
|
|
|
|
dst_vb = v4l2_m2m_dst_buf_remove(curr_ctx->fh.m2m_ctx);
|
2011-01-12 17:50:55 +08:00
|
|
|
|
2010-04-23 16:38:38 +08:00
|
|
|
curr_ctx->num_processed++;
|
|
|
|
|
2011-01-12 17:50:55 +08:00
|
|
|
v4l2_m2m_buf_done(src_vb, VB2_BUF_STATE_DONE);
|
|
|
|
v4l2_m2m_buf_done(dst_vb, VB2_BUF_STATE_DONE);
|
|
|
|
|
2010-04-23 16:38:38 +08:00
|
|
|
if (curr_ctx->num_processed == curr_ctx->translen
|
|
|
|
|| curr_ctx->aborting) {
|
2019-02-26 20:29:57 +08:00
|
|
|
dprintk(curr_ctx->dev, 2, "Finishing capture buffer fill\n");
|
2010-04-23 16:38:38 +08:00
|
|
|
curr_ctx->num_processed = 0;
|
2014-09-22 20:27:17 +08:00
|
|
|
v4l2_m2m_job_finish(vim2m_dev->m2m_dev, curr_ctx->fh.m2m_ctx);
|
2010-04-23 16:38:38 +08:00
|
|
|
} else {
|
|
|
|
device_run(curr_ctx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* video ioctls
|
|
|
|
*/
|
|
|
|
static int vidioc_querycap(struct file *file, void *priv,
|
|
|
|
struct v4l2_capability *cap)
|
|
|
|
{
|
2018-09-10 20:19:16 +08:00
|
|
|
strscpy(cap->driver, MEM2MEM_NAME, sizeof(cap->driver));
|
|
|
|
strscpy(cap->card, MEM2MEM_NAME, sizeof(cap->card));
|
2012-09-14 17:23:12 +08:00
|
|
|
snprintf(cap->bus_info, sizeof(cap->bus_info),
|
2019-03-02 00:45:04 +08:00
|
|
|
"platform:%s", MEM2MEM_NAME);
|
2010-04-23 16:38:38 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int enum_fmt(struct v4l2_fmtdesc *f, u32 type)
|
|
|
|
{
|
2019-02-01 20:58:46 +08:00
|
|
|
int i, num;
|
2014-09-22 20:27:17 +08:00
|
|
|
struct vim2m_fmt *fmt;
|
2010-04-23 16:38:38 +08:00
|
|
|
|
2019-02-01 20:58:46 +08:00
|
|
|
num = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < NUM_FORMATS; ++i) {
|
|
|
|
if (formats[i].types & type) {
|
|
|
|
/* index-th format of type type found ? */
|
|
|
|
if (num == f->index)
|
|
|
|
break;
|
|
|
|
/*
|
|
|
|
* Correct type but haven't reached our index yet,
|
|
|
|
* just increment per-type index
|
|
|
|
*/
|
|
|
|
++num;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i < NUM_FORMATS) {
|
2010-04-23 16:38:38 +08:00
|
|
|
/* Format found */
|
2019-02-01 20:58:46 +08:00
|
|
|
fmt = &formats[i];
|
2010-04-23 16:38:38 +08:00
|
|
|
f->pixelformat = fmt->fourcc;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Format not found */
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
|
|
|
|
struct v4l2_fmtdesc *f)
|
|
|
|
{
|
|
|
|
return enum_fmt(f, MEM2MEM_CAPTURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int vidioc_enum_fmt_vid_out(struct file *file, void *priv,
|
|
|
|
struct v4l2_fmtdesc *f)
|
|
|
|
{
|
|
|
|
return enum_fmt(f, MEM2MEM_OUTPUT);
|
|
|
|
}
|
|
|
|
|
2019-02-27 05:03:45 +08:00
|
|
|
static int vidioc_enum_framesizes(struct file *file, void *priv,
|
|
|
|
struct v4l2_frmsizeenum *fsize)
|
|
|
|
{
|
|
|
|
if (fsize->index != 0)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (!find_format(fsize->pixel_format))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
fsize->type = V4L2_FRMSIZE_TYPE_STEPWISE;
|
|
|
|
fsize->stepwise.min_width = MIN_W;
|
|
|
|
fsize->stepwise.min_height = MIN_H;
|
|
|
|
fsize->stepwise.max_width = MAX_W;
|
|
|
|
fsize->stepwise.max_height = MAX_H;
|
2019-02-28 14:25:50 +08:00
|
|
|
|
|
|
|
get_alignment(fsize->pixel_format,
|
|
|
|
&fsize->stepwise.step_width,
|
|
|
|
&fsize->stepwise.step_height);
|
2019-02-27 05:03:45 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-09-22 20:27:17 +08:00
|
|
|
static int vidioc_g_fmt(struct vim2m_ctx *ctx, struct v4l2_format *f)
|
2010-04-23 16:38:38 +08:00
|
|
|
{
|
2011-01-12 17:50:55 +08:00
|
|
|
struct vb2_queue *vq;
|
2014-09-22 20:27:17 +08:00
|
|
|
struct vim2m_q_data *q_data;
|
2010-04-23 16:38:38 +08:00
|
|
|
|
2013-08-26 04:27:45 +08:00
|
|
|
vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type);
|
2010-04-23 16:38:38 +08:00
|
|
|
if (!vq)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2012-06-08 15:47:34 +08:00
|
|
|
q_data = get_q_data(ctx, f->type);
|
2019-03-02 00:46:11 +08:00
|
|
|
if (!q_data)
|
|
|
|
return -EINVAL;
|
2010-04-23 16:38:38 +08:00
|
|
|
|
|
|
|
f->fmt.pix.width = q_data->width;
|
|
|
|
f->fmt.pix.height = q_data->height;
|
2011-01-12 17:50:55 +08:00
|
|
|
f->fmt.pix.field = V4L2_FIELD_NONE;
|
2010-04-23 16:38:38 +08:00
|
|
|
f->fmt.pix.pixelformat = q_data->fmt->fourcc;
|
|
|
|
f->fmt.pix.bytesperline = (q_data->width * q_data->fmt->depth) >> 3;
|
|
|
|
f->fmt.pix.sizeimage = q_data->sizeimage;
|
2012-07-18 22:33:22 +08:00
|
|
|
f->fmt.pix.colorspace = ctx->colorspace;
|
2016-07-18 19:00:20 +08:00
|
|
|
f->fmt.pix.xfer_func = ctx->xfer_func;
|
|
|
|
f->fmt.pix.ycbcr_enc = ctx->ycbcr_enc;
|
|
|
|
f->fmt.pix.quantization = ctx->quant;
|
2010-04-23 16:38:38 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int vidioc_g_fmt_vid_out(struct file *file, void *priv,
|
|
|
|
struct v4l2_format *f)
|
|
|
|
{
|
2012-07-18 21:35:37 +08:00
|
|
|
return vidioc_g_fmt(file2ctx(file), f);
|
2010-04-23 16:38:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
|
|
|
|
struct v4l2_format *f)
|
|
|
|
{
|
2012-07-18 21:35:37 +08:00
|
|
|
return vidioc_g_fmt(file2ctx(file), f);
|
2010-04-23 16:38:38 +08:00
|
|
|
}
|
|
|
|
|
2014-09-22 20:27:17 +08:00
|
|
|
static int vidioc_try_fmt(struct v4l2_format *f, struct vim2m_fmt *fmt)
|
2010-04-23 16:38:38 +08:00
|
|
|
{
|
2019-02-28 14:25:50 +08:00
|
|
|
int walign, halign;
|
2019-03-02 00:45:04 +08:00
|
|
|
/*
|
|
|
|
* V4L2 specification specifies the driver corrects the
|
|
|
|
* format struct if any of the dimensions is unsupported
|
|
|
|
*/
|
2010-04-23 16:38:38 +08:00
|
|
|
if (f->fmt.pix.height < MIN_H)
|
|
|
|
f->fmt.pix.height = MIN_H;
|
|
|
|
else if (f->fmt.pix.height > MAX_H)
|
|
|
|
f->fmt.pix.height = MAX_H;
|
|
|
|
|
|
|
|
if (f->fmt.pix.width < MIN_W)
|
|
|
|
f->fmt.pix.width = MIN_W;
|
|
|
|
else if (f->fmt.pix.width > MAX_W)
|
|
|
|
f->fmt.pix.width = MAX_W;
|
|
|
|
|
2019-02-28 14:25:50 +08:00
|
|
|
get_alignment(f->fmt.pix.pixelformat, &walign, &halign);
|
|
|
|
f->fmt.pix.width &= ~(walign - 1);
|
|
|
|
f->fmt.pix.height &= ~(halign - 1);
|
2010-04-23 16:38:38 +08:00
|
|
|
f->fmt.pix.bytesperline = (f->fmt.pix.width * fmt->depth) >> 3;
|
|
|
|
f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline;
|
2014-03-10 21:58:29 +08:00
|
|
|
f->fmt.pix.field = V4L2_FIELD_NONE;
|
2010-04-23 16:38:38 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
|
|
|
|
struct v4l2_format *f)
|
|
|
|
{
|
2014-09-22 20:27:17 +08:00
|
|
|
struct vim2m_fmt *fmt;
|
|
|
|
struct vim2m_ctx *ctx = file2ctx(file);
|
2010-04-23 16:38:38 +08:00
|
|
|
|
2019-02-27 05:03:45 +08:00
|
|
|
fmt = find_format(f->fmt.pix.pixelformat);
|
2014-03-10 21:58:24 +08:00
|
|
|
if (!fmt) {
|
|
|
|
f->fmt.pix.pixelformat = formats[0].fourcc;
|
2019-02-27 05:03:45 +08:00
|
|
|
fmt = find_format(f->fmt.pix.pixelformat);
|
2014-03-10 21:58:24 +08:00
|
|
|
}
|
2019-02-01 20:58:46 +08:00
|
|
|
if (!(fmt->types & MEM2MEM_CAPTURE)) {
|
|
|
|
v4l2_err(&ctx->dev->v4l2_dev,
|
|
|
|
"Fourcc format (0x%08x) invalid.\n",
|
|
|
|
f->fmt.pix.pixelformat);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2012-07-18 22:33:22 +08:00
|
|
|
f->fmt.pix.colorspace = ctx->colorspace;
|
2016-07-18 19:00:20 +08:00
|
|
|
f->fmt.pix.xfer_func = ctx->xfer_func;
|
|
|
|
f->fmt.pix.ycbcr_enc = ctx->ycbcr_enc;
|
|
|
|
f->fmt.pix.quantization = ctx->quant;
|
2010-04-23 16:38:38 +08:00
|
|
|
|
|
|
|
return vidioc_try_fmt(f, fmt);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int vidioc_try_fmt_vid_out(struct file *file, void *priv,
|
|
|
|
struct v4l2_format *f)
|
|
|
|
{
|
2014-09-22 20:27:17 +08:00
|
|
|
struct vim2m_fmt *fmt;
|
2019-02-01 20:58:46 +08:00
|
|
|
struct vim2m_ctx *ctx = file2ctx(file);
|
2010-04-23 16:38:38 +08:00
|
|
|
|
2019-02-27 05:03:45 +08:00
|
|
|
fmt = find_format(f->fmt.pix.pixelformat);
|
2014-03-10 21:58:24 +08:00
|
|
|
if (!fmt) {
|
|
|
|
f->fmt.pix.pixelformat = formats[0].fourcc;
|
2019-02-27 05:03:45 +08:00
|
|
|
fmt = find_format(f->fmt.pix.pixelformat);
|
2014-03-10 21:58:24 +08:00
|
|
|
}
|
2019-02-01 20:58:46 +08:00
|
|
|
if (!(fmt->types & MEM2MEM_OUTPUT)) {
|
|
|
|
v4l2_err(&ctx->dev->v4l2_dev,
|
|
|
|
"Fourcc format (0x%08x) invalid.\n",
|
|
|
|
f->fmt.pix.pixelformat);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2012-07-18 22:33:22 +08:00
|
|
|
if (!f->fmt.pix.colorspace)
|
|
|
|
f->fmt.pix.colorspace = V4L2_COLORSPACE_REC709;
|
2010-04-23 16:38:38 +08:00
|
|
|
|
|
|
|
return vidioc_try_fmt(f, fmt);
|
|
|
|
}
|
|
|
|
|
2014-09-22 20:27:17 +08:00
|
|
|
static int vidioc_s_fmt(struct vim2m_ctx *ctx, struct v4l2_format *f)
|
2010-04-23 16:38:38 +08:00
|
|
|
{
|
2014-09-22 20:27:17 +08:00
|
|
|
struct vim2m_q_data *q_data;
|
2011-01-12 17:50:55 +08:00
|
|
|
struct vb2_queue *vq;
|
2010-04-23 16:38:38 +08:00
|
|
|
|
2013-08-26 04:27:45 +08:00
|
|
|
vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type);
|
2010-04-23 16:38:38 +08:00
|
|
|
if (!vq)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2012-06-08 15:47:34 +08:00
|
|
|
q_data = get_q_data(ctx, f->type);
|
2010-04-23 16:38:38 +08:00
|
|
|
if (!q_data)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2011-01-12 17:50:55 +08:00
|
|
|
if (vb2_is_busy(vq)) {
|
2010-04-23 16:38:38 +08:00
|
|
|
v4l2_err(&ctx->dev->v4l2_dev, "%s queue busy\n", __func__);
|
2010-12-21 01:39:25 +08:00
|
|
|
return -EBUSY;
|
2010-04-23 16:38:38 +08:00
|
|
|
}
|
|
|
|
|
2019-02-27 05:03:45 +08:00
|
|
|
q_data->fmt = find_format(f->fmt.pix.pixelformat);
|
2010-04-23 16:38:38 +08:00
|
|
|
q_data->width = f->fmt.pix.width;
|
|
|
|
q_data->height = f->fmt.pix.height;
|
|
|
|
q_data->sizeimage = q_data->width * q_data->height
|
|
|
|
* q_data->fmt->depth >> 3;
|
|
|
|
|
2019-02-26 20:29:57 +08:00
|
|
|
dprintk(ctx->dev, 1,
|
|
|
|
"Format for type %s: %dx%d (%d bpp), fmt: %c%c%c%c\n",
|
|
|
|
type_name(f->type), q_data->width, q_data->height,
|
|
|
|
q_data->fmt->depth,
|
|
|
|
(q_data->fmt->fourcc & 0xff),
|
|
|
|
(q_data->fmt->fourcc >> 8) & 0xff,
|
|
|
|
(q_data->fmt->fourcc >> 16) & 0xff,
|
|
|
|
(q_data->fmt->fourcc >> 24) & 0xff);
|
2010-04-23 16:38:38 +08:00
|
|
|
|
2010-12-21 01:39:25 +08:00
|
|
|
return 0;
|
2010-04-23 16:38:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
|
|
|
|
struct v4l2_format *f)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = vidioc_try_fmt_vid_cap(file, priv, f);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2012-07-18 21:35:37 +08:00
|
|
|
return vidioc_s_fmt(file2ctx(file), f);
|
2010-04-23 16:38:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int vidioc_s_fmt_vid_out(struct file *file, void *priv,
|
|
|
|
struct v4l2_format *f)
|
|
|
|
{
|
2014-09-22 20:27:17 +08:00
|
|
|
struct vim2m_ctx *ctx = file2ctx(file);
|
2010-04-23 16:38:38 +08:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = vidioc_try_fmt_vid_out(file, priv, f);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2012-07-18 22:33:22 +08:00
|
|
|
ret = vidioc_s_fmt(file2ctx(file), f);
|
2016-07-18 19:00:20 +08:00
|
|
|
if (!ret) {
|
2012-07-18 22:33:22 +08:00
|
|
|
ctx->colorspace = f->fmt.pix.colorspace;
|
2016-07-18 19:00:20 +08:00
|
|
|
ctx->xfer_func = f->fmt.pix.xfer_func;
|
|
|
|
ctx->ycbcr_enc = f->fmt.pix.ycbcr_enc;
|
|
|
|
ctx->quant = f->fmt.pix.quantization;
|
|
|
|
}
|
2012-07-18 22:33:22 +08:00
|
|
|
return ret;
|
2010-04-23 16:38:38 +08:00
|
|
|
}
|
|
|
|
|
2014-09-22 20:27:17 +08:00
|
|
|
static int vim2m_s_ctrl(struct v4l2_ctrl *ctrl)
|
2010-04-23 16:38:38 +08:00
|
|
|
{
|
2014-09-22 20:27:17 +08:00
|
|
|
struct vim2m_ctx *ctx =
|
|
|
|
container_of(ctrl->handler, struct vim2m_ctx, hdl);
|
2010-04-23 16:38:38 +08:00
|
|
|
|
|
|
|
switch (ctrl->id) {
|
2012-06-12 17:43:49 +08:00
|
|
|
case V4L2_CID_HFLIP:
|
2012-07-18 21:35:37 +08:00
|
|
|
if (ctrl->val)
|
2012-06-12 17:43:49 +08:00
|
|
|
ctx->mode |= MEM2MEM_HFLIP;
|
|
|
|
else
|
|
|
|
ctx->mode &= ~MEM2MEM_HFLIP;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case V4L2_CID_VFLIP:
|
2012-07-18 21:35:37 +08:00
|
|
|
if (ctrl->val)
|
2012-06-12 17:43:49 +08:00
|
|
|
ctx->mode |= MEM2MEM_VFLIP;
|
|
|
|
else
|
|
|
|
ctx->mode &= ~MEM2MEM_VFLIP;
|
|
|
|
break;
|
|
|
|
|
2010-04-23 16:38:38 +08:00
|
|
|
case V4L2_CID_TRANS_TIME_MSEC:
|
2012-07-18 21:35:37 +08:00
|
|
|
ctx->transtime = ctrl->val;
|
2019-01-30 00:00:17 +08:00
|
|
|
if (ctx->transtime < 1)
|
|
|
|
ctx->transtime = 1;
|
2010-04-23 16:38:38 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case V4L2_CID_TRANS_NUM_BUFS:
|
2012-07-18 21:35:37 +08:00
|
|
|
ctx->translen = ctrl->val;
|
2010-04-23 16:38:38 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
v4l2_err(&ctx->dev->v4l2_dev, "Invalid control\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-09-22 20:27:17 +08:00
|
|
|
static const struct v4l2_ctrl_ops vim2m_ctrl_ops = {
|
|
|
|
.s_ctrl = vim2m_s_ctrl,
|
2012-07-18 21:35:37 +08:00
|
|
|
};
|
|
|
|
|
2014-09-22 20:27:17 +08:00
|
|
|
static const struct v4l2_ioctl_ops vim2m_ioctl_ops = {
|
2010-04-23 16:38:38 +08:00
|
|
|
.vidioc_querycap = vidioc_querycap,
|
|
|
|
|
|
|
|
.vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap,
|
2019-02-27 05:03:45 +08:00
|
|
|
.vidioc_enum_framesizes = vidioc_enum_framesizes,
|
2010-04-23 16:38:38 +08:00
|
|
|
.vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap,
|
|
|
|
.vidioc_try_fmt_vid_cap = vidioc_try_fmt_vid_cap,
|
|
|
|
.vidioc_s_fmt_vid_cap = vidioc_s_fmt_vid_cap,
|
|
|
|
|
|
|
|
.vidioc_enum_fmt_vid_out = vidioc_enum_fmt_vid_out,
|
|
|
|
.vidioc_g_fmt_vid_out = vidioc_g_fmt_vid_out,
|
|
|
|
.vidioc_try_fmt_vid_out = vidioc_try_fmt_vid_out,
|
|
|
|
.vidioc_s_fmt_vid_out = vidioc_s_fmt_vid_out,
|
|
|
|
|
2013-08-26 04:27:45 +08:00
|
|
|
.vidioc_reqbufs = v4l2_m2m_ioctl_reqbufs,
|
|
|
|
.vidioc_querybuf = v4l2_m2m_ioctl_querybuf,
|
|
|
|
.vidioc_qbuf = v4l2_m2m_ioctl_qbuf,
|
|
|
|
.vidioc_dqbuf = v4l2_m2m_ioctl_dqbuf,
|
2015-06-05 22:28:52 +08:00
|
|
|
.vidioc_prepare_buf = v4l2_m2m_ioctl_prepare_buf,
|
|
|
|
.vidioc_create_bufs = v4l2_m2m_ioctl_create_bufs,
|
2014-11-18 20:51:07 +08:00
|
|
|
.vidioc_expbuf = v4l2_m2m_ioctl_expbuf,
|
2010-04-23 16:38:38 +08:00
|
|
|
|
2013-08-26 04:27:45 +08:00
|
|
|
.vidioc_streamon = v4l2_m2m_ioctl_streamon,
|
|
|
|
.vidioc_streamoff = v4l2_m2m_ioctl_streamoff,
|
2010-04-23 16:38:38 +08:00
|
|
|
|
2012-07-18 21:54:59 +08:00
|
|
|
.vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
|
|
|
|
.vidioc_unsubscribe_event = v4l2_event_unsubscribe,
|
2010-04-23 16:38:38 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Queue operations
|
|
|
|
*/
|
|
|
|
|
2014-09-22 20:27:17 +08:00
|
|
|
static int vim2m_queue_setup(struct vb2_queue *vq,
|
2019-03-02 00:45:04 +08:00
|
|
|
unsigned int *nbuffers,
|
|
|
|
unsigned int *nplanes,
|
|
|
|
unsigned int sizes[],
|
|
|
|
struct device *alloc_devs[])
|
2010-04-23 16:38:38 +08:00
|
|
|
{
|
2014-09-22 20:27:17 +08:00
|
|
|
struct vim2m_ctx *ctx = vb2_get_drv_priv(vq);
|
|
|
|
struct vim2m_q_data *q_data;
|
2011-01-12 17:50:55 +08:00
|
|
|
unsigned int size, count = *nbuffers;
|
2010-04-23 16:38:38 +08:00
|
|
|
|
2012-06-08 15:47:34 +08:00
|
|
|
q_data = get_q_data(ctx, vq->type);
|
2019-03-02 00:46:11 +08:00
|
|
|
if (!q_data)
|
|
|
|
return -EINVAL;
|
2010-04-23 16:38:38 +08:00
|
|
|
|
2011-01-12 17:50:55 +08:00
|
|
|
size = q_data->width * q_data->height * q_data->fmt->depth >> 3;
|
|
|
|
|
|
|
|
while (size * count > MEM2MEM_VID_MEM_LIMIT)
|
|
|
|
(count)--;
|
2015-10-28 10:50:37 +08:00
|
|
|
*nbuffers = count;
|
|
|
|
|
|
|
|
if (*nplanes)
|
|
|
|
return sizes[0] < size ? -EINVAL : 0;
|
2010-04-23 16:38:38 +08:00
|
|
|
|
2011-01-12 17:50:55 +08:00
|
|
|
*nplanes = 1;
|
|
|
|
sizes[0] = size;
|
2010-04-23 16:38:38 +08:00
|
|
|
|
2019-02-26 20:29:57 +08:00
|
|
|
dprintk(ctx->dev, 1, "%s: get %d buffer(s) of size %d each.\n",
|
|
|
|
type_name(vq->type), count, size);
|
2010-04-23 16:38:38 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-01-16 20:01:14 +08:00
|
|
|
static int vim2m_buf_out_validate(struct vb2_buffer *vb)
|
2010-04-23 16:38:38 +08:00
|
|
|
{
|
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 21:30:30 +08:00
|
|
|
struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
|
2014-09-22 20:27:17 +08:00
|
|
|
struct vim2m_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
|
2019-01-16 20:01:14 +08:00
|
|
|
|
|
|
|
if (vbuf->field == V4L2_FIELD_ANY)
|
|
|
|
vbuf->field = V4L2_FIELD_NONE;
|
|
|
|
if (vbuf->field != V4L2_FIELD_NONE) {
|
2019-02-26 20:29:57 +08:00
|
|
|
dprintk(ctx->dev, 1, "%s field isn't supported\n", __func__);
|
2019-01-16 20:01:14 +08:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int vim2m_buf_prepare(struct vb2_buffer *vb)
|
|
|
|
{
|
|
|
|
struct vim2m_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
|
2014-09-22 20:27:17 +08:00
|
|
|
struct vim2m_q_data *q_data;
|
2010-04-23 16:38:38 +08:00
|
|
|
|
2019-02-26 20:29:57 +08:00
|
|
|
dprintk(ctx->dev, 2, "type: %s\n", type_name(vb->vb2_queue->type));
|
2010-04-23 16:38:38 +08:00
|
|
|
|
2012-06-08 15:47:34 +08:00
|
|
|
q_data = get_q_data(ctx, vb->vb2_queue->type);
|
2019-03-02 00:46:11 +08:00
|
|
|
if (!q_data)
|
|
|
|
return -EINVAL;
|
2011-01-12 17:50:55 +08:00
|
|
|
if (vb2_plane_size(vb, 0) < q_data->sizeimage) {
|
2019-02-26 20:29:57 +08:00
|
|
|
dprintk(ctx->dev, 1,
|
|
|
|
"%s data will not fit into plane (%lu < %lu)\n",
|
|
|
|
__func__, vb2_plane_size(vb, 0),
|
|
|
|
(long)q_data->sizeimage);
|
2010-04-23 16:38:38 +08:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2011-01-12 17:50:55 +08:00
|
|
|
vb2_set_plane_payload(vb, 0, q_data->sizeimage);
|
2010-04-23 16:38:38 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-09-22 20:27:17 +08:00
|
|
|
static void vim2m_buf_queue(struct vb2_buffer *vb)
|
2010-04-23 16:38:38 +08:00
|
|
|
{
|
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 21:30:30 +08:00
|
|
|
struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
|
2014-09-22 20:27:17 +08:00
|
|
|
struct vim2m_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
|
2014-03-10 21:58:28 +08:00
|
|
|
|
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 21:30:30 +08:00
|
|
|
v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vbuf);
|
2011-07-12 20:46:44 +08:00
|
|
|
}
|
|
|
|
|
2019-03-02 00:45:04 +08:00
|
|
|
static int vim2m_start_streaming(struct vb2_queue *q, unsigned int count)
|
2014-03-10 21:58:28 +08:00
|
|
|
{
|
2014-09-22 20:27:17 +08:00
|
|
|
struct vim2m_ctx *ctx = vb2_get_drv_priv(q);
|
|
|
|
struct vim2m_q_data *q_data = get_q_data(ctx, q->type);
|
2014-03-10 21:58:28 +08:00
|
|
|
|
2019-03-02 00:46:11 +08:00
|
|
|
if (!q_data)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2019-09-13 02:55:55 +08:00
|
|
|
if (V4L2_TYPE_IS_OUTPUT(q->type))
|
|
|
|
ctx->aborting = 0;
|
|
|
|
|
2014-03-10 21:58:28 +08:00
|
|
|
q_data->sequence = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-09-22 20:27:17 +08:00
|
|
|
static void vim2m_stop_streaming(struct vb2_queue *q)
|
2014-03-10 21:58:27 +08:00
|
|
|
{
|
2014-09-22 20:27:17 +08:00
|
|
|
struct vim2m_ctx *ctx = vb2_get_drv_priv(q);
|
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 21:30:30 +08:00
|
|
|
struct vb2_v4l2_buffer *vbuf;
|
2014-03-10 21:58:27 +08:00
|
|
|
|
2019-02-18 23:29:31 +08:00
|
|
|
cancel_delayed_work_sync(&ctx->work_run);
|
2019-01-11 20:07:25 +08:00
|
|
|
|
2014-03-10 21:58:27 +08:00
|
|
|
for (;;) {
|
|
|
|
if (V4L2_TYPE_IS_OUTPUT(q->type))
|
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 21:30:30 +08:00
|
|
|
vbuf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx);
|
2014-03-10 21:58:27 +08:00
|
|
|
else
|
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 21:30:30 +08:00
|
|
|
vbuf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx);
|
2019-03-02 00:45:04 +08:00
|
|
|
if (!vbuf)
|
2014-04-17 13:47:21 +08:00
|
|
|
return;
|
2018-05-21 16:54:57 +08:00
|
|
|
v4l2_ctrl_request_complete(vbuf->vb2_buf.req_obj.req,
|
|
|
|
&ctx->hdl);
|
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 21:30:30 +08:00
|
|
|
v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_ERROR);
|
2014-03-10 21:58:27 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-21 16:54:57 +08:00
|
|
|
static void vim2m_buf_request_complete(struct vb2_buffer *vb)
|
|
|
|
{
|
|
|
|
struct vim2m_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
|
|
|
|
|
|
|
|
v4l2_ctrl_request_complete(vb->req_obj.req, &ctx->hdl);
|
|
|
|
}
|
|
|
|
|
2016-09-09 07:59:10 +08:00
|
|
|
static const struct vb2_ops vim2m_qops = {
|
2014-09-22 20:27:17 +08:00
|
|
|
.queue_setup = vim2m_queue_setup,
|
2019-01-16 20:01:14 +08:00
|
|
|
.buf_out_validate = vim2m_buf_out_validate,
|
2014-09-22 20:27:17 +08:00
|
|
|
.buf_prepare = vim2m_buf_prepare,
|
|
|
|
.buf_queue = vim2m_buf_queue,
|
|
|
|
.start_streaming = vim2m_start_streaming,
|
|
|
|
.stop_streaming = vim2m_stop_streaming,
|
2013-08-26 04:27:45 +08:00
|
|
|
.wait_prepare = vb2_ops_wait_prepare,
|
|
|
|
.wait_finish = vb2_ops_wait_finish,
|
2018-05-21 16:54:57 +08:00
|
|
|
.buf_request_complete = vim2m_buf_request_complete,
|
2010-04-23 16:38:38 +08:00
|
|
|
};
|
|
|
|
|
2019-03-02 00:45:04 +08:00
|
|
|
static int queue_init(void *priv, struct vb2_queue *src_vq,
|
|
|
|
struct vb2_queue *dst_vq)
|
2010-04-23 16:38:38 +08:00
|
|
|
{
|
2014-09-22 20:27:17 +08:00
|
|
|
struct vim2m_ctx *ctx = priv;
|
2011-01-12 17:50:55 +08:00
|
|
|
int ret;
|
2010-04-23 16:38:38 +08:00
|
|
|
|
2011-01-12 17:50:55 +08:00
|
|
|
src_vq->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
|
2014-03-10 21:58:26 +08:00
|
|
|
src_vq->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF;
|
2011-01-12 17:50:55 +08:00
|
|
|
src_vq->drv_priv = ctx;
|
|
|
|
src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
|
2014-09-22 20:27:17 +08:00
|
|
|
src_vq->ops = &vim2m_qops;
|
2011-01-12 17:50:55 +08:00
|
|
|
src_vq->mem_ops = &vb2_vmalloc_memops;
|
2014-02-26 06:12:19 +08:00
|
|
|
src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
|
2019-01-30 00:00:16 +08:00
|
|
|
src_vq->lock = &ctx->vb_mutex;
|
2018-08-23 22:18:35 +08:00
|
|
|
src_vq->supports_requests = true;
|
2011-01-12 17:50:55 +08:00
|
|
|
|
|
|
|
ret = vb2_queue_init(src_vq);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
2010-04-23 16:38:38 +08:00
|
|
|
|
2011-01-12 17:50:55 +08:00
|
|
|
dst_vq->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
2014-03-10 21:58:26 +08:00
|
|
|
dst_vq->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF;
|
2011-01-12 17:50:55 +08:00
|
|
|
dst_vq->drv_priv = ctx;
|
|
|
|
dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
|
2014-09-22 20:27:17 +08:00
|
|
|
dst_vq->ops = &vim2m_qops;
|
2011-01-12 17:50:55 +08:00
|
|
|
dst_vq->mem_ops = &vb2_vmalloc_memops;
|
2014-02-26 06:12:19 +08:00
|
|
|
dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
|
2019-01-30 00:00:16 +08:00
|
|
|
dst_vq->lock = &ctx->vb_mutex;
|
2011-01-12 17:50:55 +08:00
|
|
|
|
|
|
|
return vb2_queue_init(dst_vq);
|
|
|
|
}
|
2010-04-23 16:38:38 +08:00
|
|
|
|
2019-01-30 00:00:17 +08:00
|
|
|
static struct v4l2_ctrl_config vim2m_ctrl_trans_time_msec = {
|
2014-09-22 20:27:17 +08:00
|
|
|
.ops = &vim2m_ctrl_ops,
|
2012-07-18 21:35:37 +08:00
|
|
|
.id = V4L2_CID_TRANS_TIME_MSEC,
|
|
|
|
.name = "Transaction Time (msec)",
|
|
|
|
.type = V4L2_CTRL_TYPE_INTEGER,
|
|
|
|
.min = 1,
|
|
|
|
.max = 10001,
|
2014-03-10 21:58:23 +08:00
|
|
|
.step = 1,
|
2012-07-18 21:35:37 +08:00
|
|
|
};
|
|
|
|
|
2014-09-22 20:27:17 +08:00
|
|
|
static const struct v4l2_ctrl_config vim2m_ctrl_trans_num_bufs = {
|
|
|
|
.ops = &vim2m_ctrl_ops,
|
2012-07-18 21:35:37 +08:00
|
|
|
.id = V4L2_CID_TRANS_NUM_BUFS,
|
|
|
|
.name = "Buffers Per Transaction",
|
|
|
|
.type = V4L2_CTRL_TYPE_INTEGER,
|
|
|
|
.def = 1,
|
|
|
|
.min = 1,
|
|
|
|
.max = MEM2MEM_DEF_NUM_BUFS,
|
|
|
|
.step = 1,
|
|
|
|
};
|
|
|
|
|
2010-04-23 16:38:38 +08:00
|
|
|
/*
|
|
|
|
* File operations
|
|
|
|
*/
|
2014-09-22 20:27:17 +08:00
|
|
|
static int vim2m_open(struct file *file)
|
2010-04-23 16:38:38 +08:00
|
|
|
{
|
2014-09-22 20:27:17 +08:00
|
|
|
struct vim2m_dev *dev = video_drvdata(file);
|
|
|
|
struct vim2m_ctx *ctx = NULL;
|
2012-07-18 21:35:37 +08:00
|
|
|
struct v4l2_ctrl_handler *hdl;
|
2012-07-31 14:51:25 +08:00
|
|
|
int rc = 0;
|
2010-04-23 16:38:38 +08:00
|
|
|
|
2012-07-31 14:51:25 +08:00
|
|
|
if (mutex_lock_interruptible(&dev->dev_mutex))
|
|
|
|
return -ERESTARTSYS;
|
2012-09-24 13:17:46 +08:00
|
|
|
ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
|
2012-07-31 14:51:25 +08:00
|
|
|
if (!ctx) {
|
|
|
|
rc = -ENOMEM;
|
|
|
|
goto open_unlock;
|
|
|
|
}
|
2010-04-23 16:38:38 +08:00
|
|
|
|
2012-07-18 21:35:37 +08:00
|
|
|
v4l2_fh_init(&ctx->fh, video_devdata(file));
|
|
|
|
file->private_data = &ctx->fh;
|
2010-04-23 16:38:38 +08:00
|
|
|
ctx->dev = dev;
|
2012-07-18 21:35:37 +08:00
|
|
|
hdl = &ctx->hdl;
|
|
|
|
v4l2_ctrl_handler_init(hdl, 4);
|
2014-09-22 20:27:17 +08:00
|
|
|
v4l2_ctrl_new_std(hdl, &vim2m_ctrl_ops, V4L2_CID_HFLIP, 0, 1, 1, 0);
|
|
|
|
v4l2_ctrl_new_std(hdl, &vim2m_ctrl_ops, V4L2_CID_VFLIP, 0, 1, 1, 0);
|
2019-01-30 00:00:17 +08:00
|
|
|
|
|
|
|
vim2m_ctrl_trans_time_msec.def = default_transtime;
|
2014-09-22 20:27:17 +08:00
|
|
|
v4l2_ctrl_new_custom(hdl, &vim2m_ctrl_trans_time_msec, NULL);
|
|
|
|
v4l2_ctrl_new_custom(hdl, &vim2m_ctrl_trans_num_bufs, NULL);
|
2012-07-18 21:35:37 +08:00
|
|
|
if (hdl->error) {
|
2012-08-14 13:58:56 +08:00
|
|
|
rc = hdl->error;
|
2012-07-18 21:35:37 +08:00
|
|
|
v4l2_ctrl_handler_free(hdl);
|
2016-12-20 00:12:46 +08:00
|
|
|
kfree(ctx);
|
2012-08-14 13:58:56 +08:00
|
|
|
goto open_unlock;
|
2012-07-18 21:35:37 +08:00
|
|
|
}
|
|
|
|
ctx->fh.ctrl_handler = hdl;
|
|
|
|
v4l2_ctrl_handler_setup(hdl);
|
2010-04-23 16:38:38 +08:00
|
|
|
|
2012-06-08 15:47:34 +08:00
|
|
|
ctx->q_data[V4L2_M2M_SRC].fmt = &formats[0];
|
2012-07-18 22:33:22 +08:00
|
|
|
ctx->q_data[V4L2_M2M_SRC].width = 640;
|
|
|
|
ctx->q_data[V4L2_M2M_SRC].height = 480;
|
|
|
|
ctx->q_data[V4L2_M2M_SRC].sizeimage =
|
|
|
|
ctx->q_data[V4L2_M2M_SRC].width *
|
|
|
|
ctx->q_data[V4L2_M2M_SRC].height *
|
|
|
|
(ctx->q_data[V4L2_M2M_SRC].fmt->depth >> 3);
|
|
|
|
ctx->q_data[V4L2_M2M_DST] = ctx->q_data[V4L2_M2M_SRC];
|
|
|
|
ctx->colorspace = V4L2_COLORSPACE_REC709;
|
2012-06-08 15:47:34 +08:00
|
|
|
|
2013-08-26 04:27:45 +08:00
|
|
|
ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev, ctx, &queue_init);
|
2011-01-12 17:50:55 +08:00
|
|
|
|
2019-01-30 00:00:16 +08:00
|
|
|
mutex_init(&ctx->vb_mutex);
|
|
|
|
INIT_DELAYED_WORK(&ctx->work_run, device_work);
|
|
|
|
|
2013-08-26 04:27:45 +08:00
|
|
|
if (IS_ERR(ctx->fh.m2m_ctx)) {
|
|
|
|
rc = PTR_ERR(ctx->fh.m2m_ctx);
|
2010-05-05 13:58:57 +08:00
|
|
|
|
2012-07-18 21:35:37 +08:00
|
|
|
v4l2_ctrl_handler_free(hdl);
|
2016-12-20 00:12:46 +08:00
|
|
|
v4l2_fh_exit(&ctx->fh);
|
2010-04-23 16:38:38 +08:00
|
|
|
kfree(ctx);
|
2012-07-31 14:51:25 +08:00
|
|
|
goto open_unlock;
|
2010-04-23 16:38:38 +08:00
|
|
|
}
|
|
|
|
|
2012-07-18 21:35:37 +08:00
|
|
|
v4l2_fh_add(&ctx->fh);
|
2010-04-23 16:38:38 +08:00
|
|
|
atomic_inc(&dev->num_inst);
|
|
|
|
|
2019-02-26 20:29:57 +08:00
|
|
|
dprintk(dev, 1, "Created instance: %p, m2m_ctx: %p\n",
|
2013-08-26 04:27:45 +08:00
|
|
|
ctx, ctx->fh.m2m_ctx);
|
2010-04-23 16:38:38 +08:00
|
|
|
|
2012-07-31 14:51:25 +08:00
|
|
|
open_unlock:
|
|
|
|
mutex_unlock(&dev->dev_mutex);
|
2012-08-14 13:58:56 +08:00
|
|
|
return rc;
|
2010-04-23 16:38:38 +08:00
|
|
|
}
|
|
|
|
|
2014-09-22 20:27:17 +08:00
|
|
|
static int vim2m_release(struct file *file)
|
2010-04-23 16:38:38 +08:00
|
|
|
{
|
2014-09-22 20:27:17 +08:00
|
|
|
struct vim2m_dev *dev = video_drvdata(file);
|
|
|
|
struct vim2m_ctx *ctx = file2ctx(file);
|
2010-04-23 16:38:38 +08:00
|
|
|
|
2019-02-26 20:29:57 +08:00
|
|
|
dprintk(dev, 1, "Releasing instance %p\n", ctx);
|
2010-04-23 16:38:38 +08:00
|
|
|
|
2012-07-18 21:35:37 +08:00
|
|
|
v4l2_fh_del(&ctx->fh);
|
|
|
|
v4l2_fh_exit(&ctx->fh);
|
|
|
|
v4l2_ctrl_handler_free(&ctx->hdl);
|
2012-07-31 14:51:25 +08:00
|
|
|
mutex_lock(&dev->dev_mutex);
|
2013-08-26 04:27:45 +08:00
|
|
|
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
|
2012-07-31 14:51:25 +08:00
|
|
|
mutex_unlock(&dev->dev_mutex);
|
2010-04-23 16:38:38 +08:00
|
|
|
kfree(ctx);
|
|
|
|
|
|
|
|
atomic_dec(&dev->num_inst);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-02-21 21:35:15 +08:00
|
|
|
static void vim2m_device_release(struct video_device *vdev)
|
|
|
|
{
|
|
|
|
struct vim2m_dev *dev = container_of(vdev, struct vim2m_dev, vfd);
|
|
|
|
|
|
|
|
v4l2_device_unregister(&dev->v4l2_dev);
|
|
|
|
v4l2_m2m_release(dev->m2m_dev);
|
2019-11-09 21:03:08 +08:00
|
|
|
#ifdef CONFIG_MEDIA_CONTROLLER
|
|
|
|
media_device_cleanup(&dev->mdev);
|
|
|
|
#endif
|
2019-02-21 21:35:15 +08:00
|
|
|
kfree(dev);
|
|
|
|
}
|
|
|
|
|
2014-09-22 20:27:17 +08:00
|
|
|
static const struct v4l2_file_operations vim2m_fops = {
|
2010-04-23 16:38:38 +08:00
|
|
|
.owner = THIS_MODULE,
|
2014-09-22 20:27:17 +08:00
|
|
|
.open = vim2m_open,
|
|
|
|
.release = vim2m_release,
|
2013-08-26 04:27:45 +08:00
|
|
|
.poll = v4l2_m2m_fop_poll,
|
2010-12-21 01:39:25 +08:00
|
|
|
.unlocked_ioctl = video_ioctl2,
|
2013-08-26 04:27:45 +08:00
|
|
|
.mmap = v4l2_m2m_fop_mmap,
|
2010-04-23 16:38:38 +08:00
|
|
|
};
|
|
|
|
|
2017-08-26 20:57:26 +08:00
|
|
|
static const struct video_device vim2m_videodev = {
|
2010-04-23 16:38:38 +08:00
|
|
|
.name = MEM2MEM_NAME,
|
2012-09-05 17:05:50 +08:00
|
|
|
.vfl_dir = VFL_DIR_M2M,
|
2014-09-22 20:27:17 +08:00
|
|
|
.fops = &vim2m_fops,
|
|
|
|
.ioctl_ops = &vim2m_ioctl_ops,
|
2010-04-23 16:38:38 +08:00
|
|
|
.minor = -1,
|
2019-02-21 21:35:15 +08:00
|
|
|
.release = vim2m_device_release,
|
2018-11-15 16:16:22 +08:00
|
|
|
.device_caps = V4L2_CAP_VIDEO_M2M | V4L2_CAP_STREAMING,
|
2010-04-23 16:38:38 +08:00
|
|
|
};
|
|
|
|
|
2017-08-06 16:25:19 +08:00
|
|
|
static const struct v4l2_m2m_ops m2m_ops = {
|
2010-04-23 16:38:38 +08:00
|
|
|
.device_run = device_run,
|
|
|
|
.job_ready = job_ready,
|
|
|
|
.job_abort = job_abort,
|
|
|
|
};
|
|
|
|
|
2018-05-21 16:54:57 +08:00
|
|
|
static const struct media_device_ops m2m_media_ops = {
|
|
|
|
.req_validate = vb2_request_validate,
|
2018-10-19 02:54:29 +08:00
|
|
|
.req_queue = v4l2_m2m_request_queue,
|
2018-05-21 16:54:57 +08:00
|
|
|
};
|
|
|
|
|
2014-09-22 20:27:17 +08:00
|
|
|
static int vim2m_probe(struct platform_device *pdev)
|
2010-04-23 16:38:38 +08:00
|
|
|
{
|
2014-09-22 20:27:17 +08:00
|
|
|
struct vim2m_dev *dev;
|
2010-04-23 16:38:38 +08:00
|
|
|
struct video_device *vfd;
|
|
|
|
int ret;
|
|
|
|
|
2019-02-21 21:35:15 +08:00
|
|
|
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
|
2010-04-23 16:38:38 +08:00
|
|
|
if (!dev)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev);
|
|
|
|
if (ret)
|
2019-02-21 21:35:15 +08:00
|
|
|
goto error_free;
|
2010-04-23 16:38:38 +08:00
|
|
|
|
|
|
|
atomic_set(&dev->num_inst, 0);
|
|
|
|
mutex_init(&dev->dev_mutex);
|
|
|
|
|
2015-03-10 00:33:56 +08:00
|
|
|
dev->vfd = vim2m_videodev;
|
|
|
|
vfd = &dev->vfd;
|
2010-12-21 01:39:25 +08:00
|
|
|
vfd->lock = &dev->dev_mutex;
|
2013-06-27 13:44:04 +08:00
|
|
|
vfd->v4l2_dev = &dev->v4l2_dev;
|
2010-04-23 16:38:38 +08:00
|
|
|
|
2020-02-03 19:41:18 +08:00
|
|
|
ret = video_register_device(vfd, VFL_TYPE_VIDEO, 0);
|
2010-04-23 16:38:38 +08:00
|
|
|
if (ret) {
|
|
|
|
v4l2_err(&dev->v4l2_dev, "Failed to register video device\n");
|
2019-02-21 21:35:15 +08:00
|
|
|
goto error_v4l2;
|
2010-04-23 16:38:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
video_set_drvdata(vfd, dev);
|
2013-06-27 13:44:04 +08:00
|
|
|
v4l2_info(&dev->v4l2_dev,
|
2019-03-02 00:45:04 +08:00
|
|
|
"Device registered as /dev/video%d\n", vfd->num);
|
2010-04-23 16:38:38 +08:00
|
|
|
|
|
|
|
platform_set_drvdata(pdev, dev);
|
|
|
|
|
|
|
|
dev->m2m_dev = v4l2_m2m_init(&m2m_ops);
|
|
|
|
if (IS_ERR(dev->m2m_dev)) {
|
|
|
|
v4l2_err(&dev->v4l2_dev, "Failed to init mem2mem device\n");
|
|
|
|
ret = PTR_ERR(dev->m2m_dev);
|
2019-09-08 12:12:54 +08:00
|
|
|
dev->m2m_dev = NULL;
|
2019-02-21 21:35:15 +08:00
|
|
|
goto error_dev;
|
2018-07-02 23:36:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_MEDIA_CONTROLLER
|
|
|
|
dev->mdev.dev = &pdev->dev;
|
2018-09-10 20:19:14 +08:00
|
|
|
strscpy(dev->mdev.model, "vim2m", sizeof(dev->mdev.model));
|
2019-01-30 21:39:17 +08:00
|
|
|
strscpy(dev->mdev.bus_info, "platform:vim2m",
|
|
|
|
sizeof(dev->mdev.bus_info));
|
2018-07-02 23:36:06 +08:00
|
|
|
media_device_init(&dev->mdev);
|
2018-05-21 16:54:57 +08:00
|
|
|
dev->mdev.ops = &m2m_media_ops;
|
2018-07-02 23:36:06 +08:00
|
|
|
dev->v4l2_dev.mdev = &dev->mdev;
|
|
|
|
|
2019-03-02 00:45:04 +08:00
|
|
|
ret = v4l2_m2m_register_media_controller(dev->m2m_dev, vfd,
|
|
|
|
MEDIA_ENT_F_PROC_VIDEO_SCALER);
|
2018-07-02 23:36:06 +08:00
|
|
|
if (ret) {
|
|
|
|
v4l2_err(&dev->v4l2_dev, "Failed to init mem2mem media controller\n");
|
2019-05-13 15:18:29 +08:00
|
|
|
goto error_dev;
|
2010-04-23 16:38:38 +08:00
|
|
|
}
|
|
|
|
|
2018-07-02 23:36:06 +08:00
|
|
|
ret = media_device_register(&dev->mdev);
|
|
|
|
if (ret) {
|
|
|
|
v4l2_err(&dev->v4l2_dev, "Failed to register mem2mem media device\n");
|
2019-02-21 21:35:15 +08:00
|
|
|
goto error_m2m_mc;
|
2018-07-02 23:36:06 +08:00
|
|
|
}
|
|
|
|
#endif
|
2010-04-23 16:38:38 +08:00
|
|
|
return 0;
|
|
|
|
|
2018-07-02 23:36:06 +08:00
|
|
|
#ifdef CONFIG_MEDIA_CONTROLLER
|
2019-02-21 21:35:15 +08:00
|
|
|
error_m2m_mc:
|
2018-07-02 23:36:06 +08:00
|
|
|
v4l2_m2m_unregister_media_controller(dev->m2m_dev);
|
|
|
|
#endif
|
2019-02-21 21:35:15 +08:00
|
|
|
error_dev:
|
2018-07-02 23:36:06 +08:00
|
|
|
video_unregister_device(&dev->vfd);
|
2019-05-13 15:18:29 +08:00
|
|
|
/* vim2m_device_release called by video_unregister_device to release various objects */
|
|
|
|
return ret;
|
2019-02-21 21:35:15 +08:00
|
|
|
error_v4l2:
|
2010-04-23 16:38:38 +08:00
|
|
|
v4l2_device_unregister(&dev->v4l2_dev);
|
2019-02-21 21:35:15 +08:00
|
|
|
error_free:
|
|
|
|
kfree(dev);
|
2010-04-23 16:38:38 +08:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-09-22 20:27:17 +08:00
|
|
|
static int vim2m_remove(struct platform_device *pdev)
|
2010-04-23 16:38:38 +08:00
|
|
|
{
|
2014-09-22 20:27:17 +08:00
|
|
|
struct vim2m_dev *dev = platform_get_drvdata(pdev);
|
2010-04-23 16:38:38 +08:00
|
|
|
|
2014-09-22 20:27:17 +08:00
|
|
|
v4l2_info(&dev->v4l2_dev, "Removing " MEM2MEM_NAME);
|
2018-07-02 23:36:06 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_MEDIA_CONTROLLER
|
|
|
|
media_device_unregister(&dev->mdev);
|
|
|
|
v4l2_m2m_unregister_media_controller(dev->m2m_dev);
|
|
|
|
#endif
|
2015-03-10 00:33:56 +08:00
|
|
|
video_unregister_device(&dev->vfd);
|
2010-04-23 16:38:38 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-09-22 20:27:17 +08:00
|
|
|
static struct platform_driver vim2m_pdrv = {
|
|
|
|
.probe = vim2m_probe,
|
|
|
|
.remove = vim2m_remove,
|
2010-04-23 16:38:38 +08:00
|
|
|
.driver = {
|
|
|
|
.name = MEM2MEM_NAME,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2014-09-22 20:27:17 +08:00
|
|
|
static void __exit vim2m_exit(void)
|
2010-04-23 16:38:38 +08:00
|
|
|
{
|
2014-09-22 20:27:17 +08:00
|
|
|
platform_driver_unregister(&vim2m_pdrv);
|
|
|
|
platform_device_unregister(&vim2m_pdev);
|
2010-04-23 16:38:38 +08:00
|
|
|
}
|
|
|
|
|
2014-09-22 20:27:17 +08:00
|
|
|
static int __init vim2m_init(void)
|
2010-04-23 16:38:38 +08:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
2014-09-22 20:27:17 +08:00
|
|
|
ret = platform_device_register(&vim2m_pdev);
|
2010-04-23 16:38:38 +08:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2014-09-22 20:27:17 +08:00
|
|
|
ret = platform_driver_register(&vim2m_pdrv);
|
2010-04-23 16:38:38 +08:00
|
|
|
if (ret)
|
2014-09-22 20:27:17 +08:00
|
|
|
platform_device_unregister(&vim2m_pdev);
|
2010-04-23 16:38:38 +08:00
|
|
|
|
2015-12-26 01:25:16 +08:00
|
|
|
return ret;
|
2010-04-23 16:38:38 +08:00
|
|
|
}
|
|
|
|
|
2014-09-22 20:27:17 +08:00
|
|
|
module_init(vim2m_init);
|
|
|
|
module_exit(vim2m_exit);
|