aboutsummaryrefslogtreecommitdiff
path: root/drivers/media/test-drivers
diff options
context:
space:
mode:
authorLinus Torvalds2020-12-14 11:47:37 -0800
committerLinus Torvalds2020-12-14 11:47:37 -0800
commitfab0fca1da5cdc48be051715cd9787df04fdce3a (patch)
tree5d1228cdd22bdd0675090349cf41aeef53e8a14c /drivers/media/test-drivers
parentae1985b50afaf76aaa09946ee36b59eaecb2ffae (diff)
parent7ea4d23293300ca2f225595849a4fe444fb80ea4 (diff)
Merge tag 'media/v5.11-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media
Pull media updates from Mauro Carvalho Chehab: - some rework at the uAPI pixel format docs - the smiapp driver has started to gain support for MIPI CSS camera sensors and was renamed - two new sensor drivers: ov02a10 and ov9734 - Meson gained a driver for the 2D acceleration unit - Rockchip rkisp1 driver was promoted from staging - Cedrus driver gained support for VP8 - two new remote controller keymaps were added - the usual set of fixes cleanups and driver improvements * tag 'media/v5.11-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (447 commits) media: ccs: Add support for obtaining C-PHY configuration from firmware media: ccs-pll: Print pixel rates media: ccs: Print written register values media: ccs: Add support for DDR OP SYS and OP PIX clocks media: ccs-pll: Add support for DDR OP system and pixel clocks media: ccs: Dual PLL support media: ccs-pll: Add trivial dual PLL support media: ccs-pll: Separate VT divisor limit calculation from the rest media: ccs-pll: Fix VT post-PLL divisor calculation media: ccs-pll: Make VT divisors 16-bit media: ccs-pll: Rework bounds checks media: ccs-pll: Print relevant information on PLL tree media: ccs-pll: Better separate OP and VT sub-tree calculation media: ccs-pll: Check for derating and overrating, support non-derating sensors media: ccs-pll: Split off VT subtree calculation media: ccs-pll: Add C-PHY support media: ccs-pll: Add sanity checks media: ccs-pll: Add support flexible OP PLL pixel clock divider media: ccs-pll: Support two cycles per pixel on OP domain media: ccs-pll: Add support for extended input PLL clock divider ...
Diffstat (limited to 'drivers/media/test-drivers')
-rw-r--r--drivers/media/test-drivers/vicodec/codec-fwht.c13
-rw-r--r--drivers/media/test-drivers/vicodec/codec-fwht.h32
-rw-r--r--drivers/media/test-drivers/vicodec/codec-v4l2-fwht.c88
-rw-r--r--drivers/media/test-drivers/vicodec/vicodec-core.c46
-rw-r--r--drivers/media/test-drivers/vim2m.c20
-rw-r--r--drivers/media/test-drivers/vivid/vivid-core.c66
-rw-r--r--drivers/media/test-drivers/vivid/vivid-core.h1
-rw-r--r--drivers/media/test-drivers/vivid/vivid-ctrls.c29
-rw-r--r--drivers/media/test-drivers/vivid/vivid-kthread-cap.c6
-rw-r--r--drivers/media/test-drivers/vivid/vivid-kthread-out.c6
-rw-r--r--drivers/media/test-drivers/vivid/vivid-kthread-touch.c6
-rw-r--r--drivers/media/test-drivers/vivid/vivid-sdr-cap.c6
-rw-r--r--drivers/media/test-drivers/vivid/vivid-vid-cap.c18
-rw-r--r--drivers/media/test-drivers/vivid/vivid-vid-out.c18
14 files changed, 181 insertions, 174 deletions
diff --git a/drivers/media/test-drivers/vicodec/codec-fwht.c b/drivers/media/test-drivers/vicodec/codec-fwht.c
index 31faf319e508..1ce682e1b85c 100644
--- a/drivers/media/test-drivers/vicodec/codec-fwht.c
+++ b/drivers/media/test-drivers/vicodec/codec-fwht.c
@@ -11,6 +11,7 @@
#include <linux/string.h>
#include <linux/kernel.h>
+#include <linux/videodev2.h>
#include "codec-fwht.h"
#define OVERFLOW_BIT BIT(14)
@@ -920,7 +921,7 @@ bool fwht_decode_frame(struct fwht_cframe *cf, u32 hdr_flags,
if (!decode_plane(cf, &rlco, height, width, ref->luma, ref_stride,
ref->luma_alpha_step, dst->luma, dst_stride,
dst->luma_alpha_step,
- hdr_flags & FWHT_FL_LUMA_IS_UNCOMPRESSED,
+ hdr_flags & V4L2_FWHT_FL_LUMA_IS_UNCOMPRESSED,
end_of_rlco_buf))
return false;
@@ -928,21 +929,21 @@ bool fwht_decode_frame(struct fwht_cframe *cf, u32 hdr_flags,
u32 h = height;
u32 w = width;
- if (!(hdr_flags & FWHT_FL_CHROMA_FULL_HEIGHT))
+ if (!(hdr_flags & V4L2_FWHT_FL_CHROMA_FULL_HEIGHT))
h /= 2;
- if (!(hdr_flags & FWHT_FL_CHROMA_FULL_WIDTH))
+ if (!(hdr_flags & V4L2_FWHT_FL_CHROMA_FULL_WIDTH))
w /= 2;
if (!decode_plane(cf, &rlco, h, w, ref->cb, ref_chroma_stride,
ref->chroma_step, dst->cb, dst_chroma_stride,
dst->chroma_step,
- hdr_flags & FWHT_FL_CB_IS_UNCOMPRESSED,
+ hdr_flags & V4L2_FWHT_FL_CB_IS_UNCOMPRESSED,
end_of_rlco_buf))
return false;
if (!decode_plane(cf, &rlco, h, w, ref->cr, ref_chroma_stride,
ref->chroma_step, dst->cr, dst_chroma_stride,
dst->chroma_step,
- hdr_flags & FWHT_FL_CR_IS_UNCOMPRESSED,
+ hdr_flags & V4L2_FWHT_FL_CR_IS_UNCOMPRESSED,
end_of_rlco_buf))
return false;
}
@@ -951,7 +952,7 @@ bool fwht_decode_frame(struct fwht_cframe *cf, u32 hdr_flags,
if (!decode_plane(cf, &rlco, height, width, ref->alpha, ref_stride,
ref->luma_alpha_step, dst->alpha, dst_stride,
dst->luma_alpha_step,
- hdr_flags & FWHT_FL_ALPHA_IS_UNCOMPRESSED,
+ hdr_flags & V4L2_FWHT_FL_ALPHA_IS_UNCOMPRESSED,
end_of_rlco_buf))
return false;
return true;
diff --git a/drivers/media/test-drivers/vicodec/codec-fwht.h b/drivers/media/test-drivers/vicodec/codec-fwht.h
index b6fec2b1cbca..0eab24020e9e 100644
--- a/drivers/media/test-drivers/vicodec/codec-fwht.h
+++ b/drivers/media/test-drivers/vicodec/codec-fwht.h
@@ -56,38 +56,6 @@
#define FWHT_MAGIC1 0x4f4f4f4f
#define FWHT_MAGIC2 0xffffffff
-#define FWHT_VERSION 3
-
-/* Set if this is an interlaced format */
-#define FWHT_FL_IS_INTERLACED BIT(0)
-/* Set if this is a bottom-first (NTSC) interlaced format */
-#define FWHT_FL_IS_BOTTOM_FIRST BIT(1)
-/* Set if each 'frame' contains just one field */
-#define FWHT_FL_IS_ALTERNATE BIT(2)
-/*
- * If FWHT_FL_IS_ALTERNATE was set, then this is set if this
- * 'frame' is the bottom field, else it is the top field.
- */
-#define FWHT_FL_IS_BOTTOM_FIELD BIT(3)
-/* Set if this frame is uncompressed */
-#define FWHT_FL_LUMA_IS_UNCOMPRESSED BIT(4)
-#define FWHT_FL_CB_IS_UNCOMPRESSED BIT(5)
-#define FWHT_FL_CR_IS_UNCOMPRESSED BIT(6)
-#define FWHT_FL_CHROMA_FULL_HEIGHT BIT(7)
-#define FWHT_FL_CHROMA_FULL_WIDTH BIT(8)
-#define FWHT_FL_ALPHA_IS_UNCOMPRESSED BIT(9)
-#define FWHT_FL_I_FRAME BIT(10)
-
-/* A 4-values flag - the number of components - 1 */
-#define FWHT_FL_COMPONENTS_NUM_MSK GENMASK(18, 16)
-#define FWHT_FL_COMPONENTS_NUM_OFFSET 16
-
-#define FWHT_FL_PIXENC_MSK GENMASK(20, 19)
-#define FWHT_FL_PIXENC_OFFSET 19
-#define FWHT_FL_PIXENC_YUV (1 << FWHT_FL_PIXENC_OFFSET)
-#define FWHT_FL_PIXENC_RGB (2 << FWHT_FL_PIXENC_OFFSET)
-#define FWHT_FL_PIXENC_HSV (3 << FWHT_FL_PIXENC_OFFSET)
-
/*
* A macro to calculate the needed padding in order to make sure
* both luma and chroma components resolutions are rounded up to
diff --git a/drivers/media/test-drivers/vicodec/codec-v4l2-fwht.c b/drivers/media/test-drivers/vicodec/codec-v4l2-fwht.c
index b6e39fbd8ad5..0c83678fcdad 100644
--- a/drivers/media/test-drivers/vicodec/codec-v4l2-fwht.c
+++ b/drivers/media/test-drivers/vicodec/codec-v4l2-fwht.c
@@ -11,34 +11,34 @@
#include "codec-v4l2-fwht.h"
static const struct v4l2_fwht_pixfmt_info v4l2_fwht_pixfmts[] = {
- { V4L2_PIX_FMT_YUV420, 1, 3, 2, 1, 1, 2, 2, 3, 3, FWHT_FL_P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FL_PIXENC_RGB},
+ { V4L2_PIX_FMT_ABGR32, 4, 4, 1, 4, 4, 1, 1, 4, 1, V4L2_FWHT_FL_PIXENC_RGB},
+ { V4L2_PIX_FMT_RGB32, 4, 4, 1, 4, 4, 1, 1, 4, 1, V4L2_FWHT_FL_PIXENC_RGB},
+ { V4L2_PIX_FMT_XRGB32, 4, 4, 1, 4, 4, 1, 1, 4, 1, V4L2_FWHT_FL_PIXENC_RGB},
+ { V4L2_PIX_FMT_ARGB32, 4, 4, 1, 4, 4, 1, 1, 4, 1, V4L2_FWHT_FL_PIXENC_RGB},
+ { V4L2_PIX_FMT_BGRX32, 4, 4, 1, 4, 4, 1, 1, 4, 1, V4L2_FWHT_FL_PIXENC_RGB},
+ { V4L2_PIX_FMT_BGRA32, 4, 4, 1, 4, 4, 1, 1, 4, 1, V4L2_FWHT_FL_PIXENC_RGB},
+ { V4L2_PIX_FMT_RGBX32, 4, 4, 1, 4, 4, 1, 1, 4, 1, V4L2_FWHT_FL_PIXENC_RGB},
+ { V4L2_PIX_FMT_RGBA32, 4, 4, 1, 4, 4, 1, 1, 4, 1, V4L2_FWHT_FL_PIXENC_RGB},
+ { V4L2_PIX_FMT_HSV32, 4, 4, 1, 4, 4, 1, 1, 4, 1, V4L2_FWHT_FL_PIXENC_HSV},
+ { V4L2_PIX_FMT_GREY, 1, 1, 1, 1, 0, 1, 1, 1, 1, V4L2_FWHT_FL_PIXENC_RGB},
};
bool v4l2_fwht_validate_fmt(const struct v4l2_fwht_pixfmt_info *info,
@@ -251,25 +251,25 @@ int v4l2_fwht_encode(struct v4l2_fwht_state *state, u8 *p_in, u8 *p_out)
p_hdr = (struct fwht_cframe_hdr *)p_out;
p_hdr->magic1 = FWHT_MAGIC1;
p_hdr->magic2 = FWHT_MAGIC2;
- p_hdr->version = htonl(FWHT_VERSION);
+ p_hdr->version = htonl(V4L2_FWHT_VERSION);
p_hdr->width = htonl(state->visible_width);
p_hdr->height = htonl(state->visible_height);
- flags |= (info->components_num - 1) << FWHT_FL_COMPONENTS_NUM_OFFSET;
+ flags |= (info->components_num - 1) << V4L2_FWHT_FL_COMPONENTS_NUM_OFFSET;
flags |= info->pixenc;
if (encoding & FWHT_LUMA_UNENCODED)
- flags |= FWHT_FL_LUMA_IS_UNCOMPRESSED;
+ flags |= V4L2_FWHT_FL_LUMA_IS_UNCOMPRESSED;
if (encoding & FWHT_CB_UNENCODED)
- flags |= FWHT_FL_CB_IS_UNCOMPRESSED;
+ flags |= V4L2_FWHT_FL_CB_IS_UNCOMPRESSED;
if (encoding & FWHT_CR_UNENCODED)
- flags |= FWHT_FL_CR_IS_UNCOMPRESSED;
+ flags |= V4L2_FWHT_FL_CR_IS_UNCOMPRESSED;
if (encoding & FWHT_ALPHA_UNENCODED)
- flags |= FWHT_FL_ALPHA_IS_UNCOMPRESSED;
+ flags |= V4L2_FWHT_FL_ALPHA_IS_UNCOMPRESSED;
if (!(encoding & FWHT_FRAME_PCODED))
- flags |= FWHT_FL_I_FRAME;
+ flags |= V4L2_FWHT_FL_I_FRAME;
if (rf.height_div == 1)
- flags |= FWHT_FL_CHROMA_FULL_HEIGHT;
+ flags |= V4L2_FWHT_FL_CHROMA_FULL_HEIGHT;
if (rf.width_div == 1)
- flags |= FWHT_FL_CHROMA_FULL_WIDTH;
+ flags |= V4L2_FWHT_FL_CHROMA_FULL_WIDTH;
p_hdr->flags = htonl(flags);
p_hdr->colorspace = htonl(state->colorspace);
p_hdr->xfer_func = htonl(state->xfer_func);
@@ -299,9 +299,9 @@ int v4l2_fwht_decode(struct v4l2_fwht_state *state, u8 *p_in, u8 *p_out)
info = state->info;
version = ntohl(state->header.version);
- if (!version || version > FWHT_VERSION) {
+ if (!version || version > V4L2_FWHT_VERSION) {
pr_err("version %d is not supported, current version is %d\n",
- version, FWHT_VERSION);
+ version, V4L2_FWHT_VERSION);
return -EINVAL;
}
@@ -317,10 +317,10 @@ int v4l2_fwht_decode(struct v4l2_fwht_state *state, u8 *p_in, u8 *p_out)
flags = ntohl(state->header.flags);
if (version >= 2) {
- if ((flags & FWHT_FL_PIXENC_MSK) != info->pixenc)
+ if ((flags & V4L2_FWHT_FL_PIXENC_MSK) != info->pixenc)
return -EINVAL;
- components_num = 1 + ((flags & FWHT_FL_COMPONENTS_NUM_MSK) >>
- FWHT_FL_COMPONENTS_NUM_OFFSET);
+ components_num = 1 + ((flags & V4L2_FWHT_FL_COMPONENTS_NUM_MSK) >>
+ V4L2_FWHT_FL_COMPONENTS_NUM_OFFSET);
}
if (components_num != info->components_num)
@@ -333,8 +333,8 @@ int v4l2_fwht_decode(struct v4l2_fwht_state *state, u8 *p_in, u8 *p_out)
cf.rlc_data = (__be16 *)p_in;
cf.size = ntohl(state->header.size);
- hdr_width_div = (flags & FWHT_FL_CHROMA_FULL_WIDTH) ? 1 : 2;
- hdr_height_div = (flags & FWHT_FL_CHROMA_FULL_HEIGHT) ? 1 : 2;
+ hdr_width_div = (flags & V4L2_FWHT_FL_CHROMA_FULL_WIDTH) ? 1 : 2;
+ hdr_height_div = (flags & V4L2_FWHT_FL_CHROMA_FULL_HEIGHT) ? 1 : 2;
if (hdr_width_div != info->width_div ||
hdr_height_div != info->height_div)
return -EINVAL;
diff --git a/drivers/media/test-drivers/vicodec/vicodec-core.c b/drivers/media/test-drivers/vicodec/vicodec-core.c
index 0e115683f8da..025f3ff77302 100644
--- a/drivers/media/test-drivers/vicodec/vicodec-core.c
+++ b/drivers/media/test-drivers/vicodec/vicodec-core.c
@@ -200,14 +200,14 @@ static void copy_cap_to_ref(const u8 *cap, const struct v4l2_fwht_pixfmt_info *i
static bool validate_by_version(unsigned int flags, unsigned int version)
{
- if (!version || version > FWHT_VERSION)
+ if (!version || version > V4L2_FWHT_VERSION)
return false;
if (version >= 2) {
unsigned int components_num = 1 +
- ((flags & FWHT_FL_COMPONENTS_NUM_MSK) >>
- FWHT_FL_COMPONENTS_NUM_OFFSET);
- unsigned int pixenc = flags & FWHT_FL_PIXENC_MSK;
+ ((flags & V4L2_FWHT_FL_COMPONENTS_NUM_MSK) >>
+ V4L2_FWHT_FL_COMPONENTS_NUM_OFFSET);
+ unsigned int pixenc = flags & V4L2_FWHT_FL_PIXENC_MSK;
if (components_num == 0 || components_num > 4 || !pixenc)
return false;
@@ -219,18 +219,18 @@ static bool validate_stateless_params_flags(const struct v4l2_ctrl_fwht_params *
const struct v4l2_fwht_pixfmt_info *cur_info)
{
unsigned int width_div =
- (params->flags & FWHT_FL_CHROMA_FULL_WIDTH) ? 1 : 2;
+ (params->flags & V4L2_FWHT_FL_CHROMA_FULL_WIDTH) ? 1 : 2;
unsigned int height_div =
- (params->flags & FWHT_FL_CHROMA_FULL_HEIGHT) ? 1 : 2;
+ (params->flags & V4L2_FWHT_FL_CHROMA_FULL_HEIGHT) ? 1 : 2;
unsigned int components_num = 3;
unsigned int pixenc = 0;
if (params->version < 3)
return false;
- components_num = 1 + ((params->flags & FWHT_FL_COMPONENTS_NUM_MSK) >>
- FWHT_FL_COMPONENTS_NUM_OFFSET);
- pixenc = (params->flags & FWHT_FL_PIXENC_MSK);
+ components_num = 1 + ((params->flags & V4L2_FWHT_FL_COMPONENTS_NUM_MSK) >>
+ V4L2_FWHT_FL_COMPONENTS_NUM_OFFSET);
+ pixenc = (params->flags & V4L2_FWHT_FL_PIXENC_MSK);
if (v4l2_fwht_validate_fmt(cur_info, width_div, height_div,
components_num, pixenc))
return true;
@@ -278,7 +278,7 @@ static int device_process(struct vicodec_ctx *ctx,
* set the reference buffer from the reference timestamp
* only if this is a P-frame
*/
- if (!(ntohl(ctx->state.header.flags) & FWHT_FL_I_FRAME)) {
+ if (!(ntohl(ctx->state.header.flags) & V4L2_FWHT_FL_I_FRAME)) {
struct vb2_buffer *ref_vb2_buf;
int ref_buf_idx;
struct vb2_queue *vq_cap =
@@ -331,7 +331,7 @@ static int device_process(struct vicodec_ctx *ctx,
copy_cap_to_ref(p_dst, ctx->state.info, &ctx->state);
vb2_set_plane_payload(&dst_vb->vb2_buf, 0, q_dst->sizeimage);
- if (ntohl(ctx->state.header.flags) & FWHT_FL_I_FRAME)
+ if (ntohl(ctx->state.header.flags) & V4L2_FWHT_FL_I_FRAME)
dst_vb->flags |= V4L2_BUF_FLAG_KEYFRAME;
else
dst_vb->flags |= V4L2_BUF_FLAG_PFRAME;
@@ -480,16 +480,16 @@ static const struct v4l2_fwht_pixfmt_info *
info_from_header(const struct fwht_cframe_hdr *p_hdr)
{
unsigned int flags = ntohl(p_hdr->flags);
- unsigned int width_div = (flags & FWHT_FL_CHROMA_FULL_WIDTH) ? 1 : 2;
- unsigned int height_div = (flags & FWHT_FL_CHROMA_FULL_HEIGHT) ? 1 : 2;
+ unsigned int width_div = (flags & V4L2_FWHT_FL_CHROMA_FULL_WIDTH) ? 1 : 2;
+ unsigned int height_div = (flags & V4L2_FWHT_FL_CHROMA_FULL_HEIGHT) ? 1 : 2;
unsigned int components_num = 3;
unsigned int pixenc = 0;
unsigned int version = ntohl(p_hdr->version);
if (version >= 2) {
- components_num = 1 + ((flags & FWHT_FL_COMPONENTS_NUM_MSK) >>
- FWHT_FL_COMPONENTS_NUM_OFFSET);
- pixenc = (flags & FWHT_FL_PIXENC_MSK);
+ components_num = 1 + ((flags & V4L2_FWHT_FL_COMPONENTS_NUM_MSK) >>
+ V4L2_FWHT_FL_COMPONENTS_NUM_OFFSET);
+ pixenc = (flags & V4L2_FWHT_FL_PIXENC_MSK);
}
return v4l2_fwht_find_nth_fmt(width_div, height_div,
components_num, pixenc, 0);
@@ -522,8 +522,8 @@ static void update_capture_data_from_header(struct vicodec_ctx *ctx)
const struct fwht_cframe_hdr *p_hdr = &ctx->state.header;
const struct v4l2_fwht_pixfmt_info *info = info_from_header(p_hdr);
unsigned int flags = ntohl(p_hdr->flags);
- unsigned int hdr_width_div = (flags & FWHT_FL_CHROMA_FULL_WIDTH) ? 1 : 2;
- unsigned int hdr_height_div = (flags & FWHT_FL_CHROMA_FULL_HEIGHT) ? 1 : 2;
+ unsigned int hdr_width_div = (flags & V4L2_FWHT_FL_CHROMA_FULL_WIDTH) ? 1 : 2;
+ unsigned int hdr_height_div = (flags & V4L2_FWHT_FL_CHROMA_FULL_HEIGHT) ? 1 : 2;
/*
* This function should not be used by a stateless codec since
@@ -657,8 +657,8 @@ restart:
if (!is_header_valid(&ctx->state.header) && ctx->comp_has_frame)
return 1;
flags = ntohl(ctx->state.header.flags);
- hdr_width_div = (flags & FWHT_FL_CHROMA_FULL_WIDTH) ? 1 : 2;
- hdr_height_div = (flags & FWHT_FL_CHROMA_FULL_HEIGHT) ? 1 : 2;
+ hdr_width_div = (flags & V4L2_FWHT_FL_CHROMA_FULL_WIDTH) ? 1 : 2;
+ hdr_height_div = (flags & V4L2_FWHT_FL_CHROMA_FULL_HEIGHT) ? 1 : 2;
if (ntohl(ctx->state.header.width) != q_dst->visible_width ||
ntohl(ctx->state.header.height) != q_dst->visible_height ||
@@ -1746,7 +1746,7 @@ static int vicodec_try_ctrl(struct v4l2_ctrl *ctrl)
V4L2_BUF_TYPE_VIDEO_CAPTURE);
switch (ctrl->id) {
- case V4L2_CID_MPEG_VIDEO_FWHT_PARAMS:
+ case V4L2_CID_STATELESS_FWHT_PARAMS:
if (!q_dst->info)
return -EINVAL;
params = ctrl->p_new.p_fwht_params;
@@ -1799,7 +1799,7 @@ static int vicodec_s_ctrl(struct v4l2_ctrl *ctrl)
case V4L2_CID_FWHT_P_FRAME_QP:
ctx->state.p_frame_qp = ctrl->val;
return 0;
- case V4L2_CID_MPEG_VIDEO_FWHT_PARAMS:
+ case V4L2_CID_STATELESS_FWHT_PARAMS:
params = ctrl->p_new.p_fwht_params;
update_header_from_stateless_params(ctx, params);
ctx->state.ref_frame_ts = params->backward_ref_ts;
@@ -1815,7 +1815,7 @@ static const struct v4l2_ctrl_ops vicodec_ctrl_ops = {
static const struct v4l2_ctrl_config vicodec_ctrl_stateless_state = {
.ops = &vicodec_ctrl_ops,
- .id = V4L2_CID_MPEG_VIDEO_FWHT_PARAMS,
+ .id = V4L2_CID_STATELESS_FWHT_PARAMS,
.elem_size = sizeof(struct v4l2_ctrl_fwht_params),
};
diff --git a/drivers/media/test-drivers/vim2m.c b/drivers/media/test-drivers/vim2m.c
index a776bb8e0e09..331a9053a0ed 100644
--- a/drivers/media/test-drivers/vim2m.c
+++ b/drivers/media/test-drivers/vim2m.c
@@ -1325,12 +1325,6 @@ static int vim2m_probe(struct platform_device *pdev)
vfd->lock = &dev->dev_mutex;
vfd->v4l2_dev = &dev->v4l2_dev;
- ret = video_register_device(vfd, VFL_TYPE_VIDEO, 0);
- if (ret) {
- v4l2_err(&dev->v4l2_dev, "Failed to register video device\n");
- goto error_v4l2;
- }
-
video_set_drvdata(vfd, dev);
v4l2_info(&dev->v4l2_dev,
"Device registered as /dev/video%d\n", vfd->num);
@@ -1345,6 +1339,12 @@ static int vim2m_probe(struct platform_device *pdev)
goto error_dev;
}
+ ret = video_register_device(vfd, VFL_TYPE_VIDEO, 0);
+ if (ret) {
+ v4l2_err(&dev->v4l2_dev, "Failed to register video device\n");
+ goto error_m2m;
+ }
+
#ifdef CONFIG_MEDIA_CONTROLLER
dev->mdev.dev = &pdev->dev;
strscpy(dev->mdev.model, "vim2m", sizeof(dev->mdev.model));
@@ -1358,7 +1358,7 @@ static int vim2m_probe(struct platform_device *pdev)
MEDIA_ENT_F_PROC_VIDEO_SCALER);
if (ret) {
v4l2_err(&dev->v4l2_dev, "Failed to init mem2mem media controller\n");
- goto error_dev;
+ goto error_v4l2;
}
ret = media_device_register(&dev->mdev);
@@ -1373,11 +1373,13 @@ static int vim2m_probe(struct platform_device *pdev)
error_m2m_mc:
v4l2_m2m_unregister_media_controller(dev->m2m_dev);
#endif
-error_dev:
+error_v4l2:
video_unregister_device(&dev->vfd);
/* vim2m_device_release called by video_unregister_device to release various objects */
return ret;
-error_v4l2:
+error_m2m:
+ v4l2_m2m_release(dev->m2m_dev);
+error_dev:
v4l2_device_unregister(&dev->v4l2_dev);
error_free:
kfree(dev);
diff --git a/drivers/media/test-drivers/vivid/vivid-core.c b/drivers/media/test-drivers/vivid/vivid-core.c
index aa8d350fd682..0dc65ef3aa14 100644
--- a/drivers/media/test-drivers/vivid/vivid-core.c
+++ b/drivers/media/test-drivers/vivid/vivid-core.c
@@ -547,11 +547,13 @@ static int vivid_s_fmt_cap_mplane(struct file *file, void *priv,
return vidioc_s_fmt_vid_cap_mplane(file, priv, f);
}
-static bool vivid_is_in_use(struct video_device *vdev)
+static bool vivid_is_in_use(bool valid, struct video_device *vdev)
{
unsigned long flags;
bool res;
+ if (!valid)
+ return false;
spin_lock_irqsave(&vdev->fh_lock, flags);
res = !list_empty(&vdev->fh_list);
spin_unlock_irqrestore(&vdev->fh_lock, flags);
@@ -560,20 +562,46 @@ static bool vivid_is_in_use(struct video_device *vdev)
static bool vivid_is_last_user(struct vivid_dev *dev)
{
- unsigned uses = vivid_is_in_use(&dev->vid_cap_dev) +
- vivid_is_in_use(&dev->vid_out_dev) +
- vivid_is_in_use(&dev->vbi_cap_dev) +
- vivid_is_in_use(&dev->vbi_out_dev) +
- vivid_is_in_use(&dev->sdr_cap_dev) +
- vivid_is_in_use(&dev->radio_rx_dev) +
- vivid_is_in_use(&dev->radio_tx_dev) +
- vivid_is_in_use(&dev->meta_cap_dev) +
- vivid_is_in_use(&dev->meta_out_dev) +
- vivid_is_in_use(&dev->touch_cap_dev);
+ unsigned int uses =
+ vivid_is_in_use(dev->has_vid_cap, &dev->vid_cap_dev) +
+ vivid_is_in_use(dev->has_vid_out, &dev->vid_out_dev) +
+ vivid_is_in_use(dev->has_vbi_cap, &dev->vbi_cap_dev) +
+ vivid_is_in_use(dev->has_vbi_out, &dev->vbi_out_dev) +
+ vivid_is_in_use(dev->has_radio_rx, &dev->radio_rx_dev) +
+ vivid_is_in_use(dev->has_radio_tx, &dev->radio_tx_dev) +
+ vivid_is_in_use(dev->has_sdr_cap, &dev->sdr_cap_dev) +
+ vivid_is_in_use(dev->has_meta_cap, &dev->meta_cap_dev) +
+ vivid_is_in_use(dev->has_meta_out, &dev->meta_out_dev) +
+ vivid_is_in_use(dev->has_touch_cap, &dev->touch_cap_dev);
return uses == 1;
}
+static void vivid_reconnect(struct vivid_dev *dev)
+{
+ if (dev->has_vid_cap)
+ set_bit(V4L2_FL_REGISTERED, &dev->vid_cap_dev.flags);
+ if (dev->has_vid_out)
+ set_bit(V4L2_FL_REGISTERED, &dev->vid_out_dev.flags);
+ if (dev->has_vbi_cap)
+ set_bit(V4L2_FL_REGISTERED, &dev->vbi_cap_dev.flags);
+ if (dev->has_vbi_out)
+ set_bit(V4L2_FL_REGISTERED, &dev->vbi_out_dev.flags);
+ if (dev->has_radio_rx)
+ set_bit(V4L2_FL_REGISTERED, &dev->radio_rx_dev.flags);
+ if (dev->has_radio_tx)
+ set_bit(V4L2_FL_REGISTERED, &dev->radio_tx_dev.flags);
+ if (dev->has_sdr_cap)
+ set_bit(V4L2_FL_REGISTERED, &dev->sdr_cap_dev.flags);
+ if (dev->has_meta_cap)
+ set_bit(V4L2_FL_REGISTERED, &dev->meta_cap_dev.flags);
+ if (dev->has_meta_out)
+ set_bit(V4L2_FL_REGISTERED, &dev->meta_out_dev.flags);
+ if (dev->has_touch_cap)
+ set_bit(V4L2_FL_REGISTERED, &dev->touch_cap_dev.flags);
+ dev->disconnect_error = false;
+}
+
static int vivid_fop_release(struct file *file)
{
struct vivid_dev *dev = video_drvdata(file);
@@ -581,23 +609,15 @@ static int vivid_fop_release(struct file *file)
mutex_lock(&dev->mutex);
if (!no_error_inj && v4l2_fh_is_singular_file(file) &&
- !video_is_registered(vdev) && vivid_is_last_user(dev)) {
+ dev->disconnect_error && !video_is_registered(vdev) &&
+ vivid_is_last_user(dev)) {
/*
* I am the last user of this driver, and a disconnect
* was forced (since this video_device is unregistered),
* so re-register all video_device's again.
*/
v4l2_info(&dev->v4l2_dev, "reconnect\n");
- set_bit(V4L2_FL_REGISTERED, &dev->vid_cap_dev.flags);
- set_bit(V4L2_FL_REGISTERED, &dev->vid_out_dev.flags);
- set_bit(V4L2_FL_REGISTERED, &dev->vbi_cap_dev.flags);
- set_bit(V4L2_FL_REGISTERED, &dev->vbi_out_dev.flags);
- set_bit(V4L2_FL_REGISTERED, &dev->sdr_cap_dev.flags);
- set_bit(V4L2_FL_REGISTERED, &dev->radio_rx_dev.flags);
- set_bit(V4L2_FL_REGISTERED, &dev->radio_tx_dev.flags);
- set_bit(V4L2_FL_REGISTERED, &dev->meta_cap_dev.flags);
- set_bit(V4L2_FL_REGISTERED, &dev->meta_out_dev.flags);
- set_bit(V4L2_FL_REGISTERED, &dev->touch_cap_dev.flags);
+ vivid_reconnect(dev);
}
mutex_unlock(&dev->mutex);
if (file->private_data == dev->overlay_cap_owner)
@@ -1968,6 +1988,8 @@ static int vivid_remove(struct platform_device *pdev)
if (!dev)
continue;
+ if (dev->disconnect_error)
+ vivid_reconnect(dev);
#ifdef CONFIG_MEDIA_CONTROLLER
media_device_unregister(&dev->mdev);
#endif
diff --git a/drivers/media/test-drivers/vivid/vivid-core.h b/drivers/media/test-drivers/vivid/vivid-core.h
index 99e69b8f770f..9c2d1470b597 100644
--- a/drivers/media/test-drivers/vivid/vivid-core.h
+++ b/drivers/media/test-drivers/vivid/vivid-core.h
@@ -303,6 +303,7 @@ struct vivid_dev {
struct fb_fix_screeninfo fb_fix;
/* Error injection */
+ bool disconnect_error;
bool queue_setup_error;
bool buf_prepare_error;
bool start_streaming_error;
diff --git a/drivers/media/test-drivers/vivid/vivid-ctrls.c b/drivers/media/test-drivers/vivid/vivid-ctrls.c
index 334130568dcb..11e3b5617f52 100644
--- a/drivers/media/test-drivers/vivid/vivid-ctrls.c
+++ b/drivers/media/test-drivers/vivid/vivid-ctrls.c
@@ -107,14 +107,27 @@ static int vivid_user_gen_s_ctrl(struct v4l2_ctrl *ctrl)
switch (ctrl->id) {
case VIVID_CID_DISCONNECT:
v4l2_info(&dev->v4l2_dev, "disconnect\n");
- clear_bit(V4L2_FL_REGISTERED, &dev->vid_cap_dev.flags);
- clear_bit(V4L2_FL_REGISTERED, &dev->vid_out_dev.flags);
- clear_bit(V4L2_FL_REGISTERED, &dev->vbi_cap_dev.flags);
- clear_bit(V4L2_FL_REGISTERED, &dev->vbi_out_dev.flags);
- clear_bit(V4L2_FL_REGISTERED, &dev->sdr_cap_dev.flags);
- clear_bit(V4L2_FL_REGISTERED, &dev->radio_rx_dev.flags);
- clear_bit(V4L2_FL_REGISTERED, &dev->radio_tx_dev.flags);
- clear_bit(V4L2_FL_REGISTERED, &dev->meta_cap_dev.flags);
+ dev->disconnect_error = true;
+ if (dev->has_vid_cap)
+ clear_bit(V4L2_FL_REGISTERED, &dev->vid_cap_dev.flags);
+ if (dev->has_vid_out)
+ clear_bit(V4L2_FL_REGISTERED, &dev->vid_out_dev.flags);
+ if (dev->has_vbi_cap)
+ clear_bit(V4L2_FL_REGISTERED, &dev->vbi_cap_dev.flags);
+ if (dev->has_vbi_out)
+ clear_bit(V4L2_FL_REGISTERED, &dev->vbi_out_dev.flags);
+ if (dev->has_radio_rx)
+ clear_bit(V4L2_FL_REGISTERED, &dev->radio_rx_dev.flags);
+ if (dev->has_radio_tx)
+ clear_bit(V4L2_FL_REGISTERED, &dev->radio_tx_dev.flags);
+ if (dev->has_sdr_cap)
+ clear_bit(V4L2_FL_REGISTERED, &dev->sdr_cap_dev.flags);
+ if (dev->has_meta_cap)
+ clear_bit(V4L2_FL_REGISTERED, &dev->meta_cap_dev.flags);
+ if (dev->has_meta_out)
+ clear_bit(V4L2_FL_REGISTERED, &dev->meta_out_dev.flags);
+ if (dev->has_touch_cap)
+ clear_bit(V4L2_FL_REGISTERED, &dev->touch_cap_dev.flags);
break;
case VIVID_CID_BUTTON:
dev->button_pressed = 30;
diff --git a/drivers/media/test-drivers/vivid/vivid-kthread-cap.c b/drivers/media/test-drivers/vivid/vivid-kthread-cap.c
index 01a9d671b947..67fb3c00f9ad 100644
--- a/drivers/media/test-drivers/vivid/vivid-kthread-cap.c
+++ b/drivers/media/test-drivers/vivid/vivid-kthread-cap.c
@@ -819,7 +819,7 @@ static int vivid_thread_vid_cap(void *data)
break;
if (!mutex_trylock(&dev->mutex)) {
- schedule_timeout_uninterruptible(1);
+ schedule();
continue;
}
@@ -888,7 +888,9 @@ static int vivid_thread_vid_cap(void *data)
next_jiffies_since_start = jiffies_since_start;
wait_jiffies = next_jiffies_since_start - jiffies_since_start;
- schedule_timeout_interruptible(wait_jiffies ? wait_jiffies : 1);
+ while (jiffies - cur_jiffies < wait_jiffies &&
+ !kthread_should_stop())
+ schedule();
}
dprintk(dev, 1, "Video Capture Thread End\n");
return 0;
diff --git a/drivers/media/test-drivers/vivid/vivid-kthread-out.c b/drivers/media/test-drivers/vivid/vivid-kthread-out.c
index 6780687978f9..79c57d14ac4e 100644
--- a/drivers/media/test-drivers/vivid/vivid-kthread-out.c
+++ b/drivers/media/test-drivers/vivid/vivid-kthread-out.c
@@ -167,7 +167,7 @@ static int vivid_thread_vid_out(void *data)
break;
if (!mutex_trylock(&dev->mutex)) {
- schedule_timeout_uninterruptible(1);
+ schedule();
continue;
}
@@ -233,7 +233,9 @@ static int vivid_thread_vid_out(void *data)
next_jiffies_since_start = jiffies_since_start;
wait_jiffies = next_jiffies_since_start - jiffies_since_start;
- schedule_timeout_interruptible(wait_jiffies ? wait_jiffies : 1);
+ while (jiffies - cur_jiffies < wait_jiffies &&
+ !kthread_should_stop())
+ schedule();
}
dprintk(dev, 1, "Video Output Thread End\n");
return 0;
diff --git a/drivers/media/test-drivers/vivid/vivid-kthread-touch.c b/drivers/media/test-drivers/vivid/vivid-kthread-touch.c
index 674507b5ccb5..38fdfee79498 100644
--- a/drivers/media/test-drivers/vivid/vivid-kthread-touch.c
+++ b/drivers/media/test-drivers/vivid/vivid-kthread-touch.c
@@ -69,7 +69,7 @@ static int vivid_thread_touch_cap(void *data)
break;
if (!mutex_trylock(&dev->mutex)) {
- schedule_timeout_uninterruptible(1);
+ schedule();
continue;
}
cur_jiffies = jiffies;
@@ -128,7 +128,9 @@ static int vivid_thread_touch_cap(void *data)
next_jiffies_since_start = jiffies_since_start;
wait_jiffies = next_jiffies_since_start - jiffies_since_start;
- schedule_timeout_interruptible(wait_jiffies ? wait_jiffies : 1);
+ while (jiffies - cur_jiffies < wait_jiffies &&
+ !kthread_should_stop())
+ schedule();
}
dprintk(dev, 1, "Touch Capture Thread End\n");
return 0;
diff --git a/drivers/media/test-drivers/vivid/vivid-sdr-cap.c b/drivers/media/test-drivers/vivid/vivid-sdr-cap.c
index 2b7522e16efc..a1e52708b7ca 100644
--- a/drivers/media/test-drivers/vivid/vivid-sdr-cap.c
+++ b/drivers/media/test-drivers/vivid/vivid-sdr-cap.c
@@ -142,7 +142,7 @@ static int vivid_thread_sdr_cap(void *data)
break;
if (!mutex_trylock(&dev->mutex)) {
- schedule_timeout_uninterruptible(1);
+ schedule();
continue;
}
@@ -201,7 +201,9 @@ static int vivid_thread_sdr_cap(void *data)
next_jiffies_since_start = jiffies_since_start;
wait_jiffies = next_jiffies_since_start - jiffies_since_start;
- schedule_timeout_interruptible(wait_jiffies ? wait_jiffies : 1);
+ while (jiffies - cur_jiffies < wait_jiffies &&
+ !kthread_should_stop())
+ schedule();
}
dprintk(dev, 1, "SDR Capture Thread End\n");
return 0;
diff --git a/drivers/media/test-drivers/vivid/vivid-vid-cap.c b/drivers/media/test-drivers/vivid/vivid-vid-cap.c
index eadf28ab1e39..b9caa4b26209 100644
--- a/drivers/media/test-drivers/vivid/vivid-vid-cap.c
+++ b/drivers/media/test-drivers/vivid/vivid-vid-cap.c
@@ -1107,11 +1107,9 @@ int vidioc_g_fmt_vid_overlay(struct file *file, void *priv,
((compose->width + 7) / 8) * compose->height))
return -EFAULT;
}
- if (clipcount && win->clips) {
- if (copy_to_user(win->clips, dev->clips_cap,
- clipcount * sizeof(dev->clips_cap[0])))
- return -EFAULT;
- }
+ if (clipcount && win->clips)
+ memcpy(win->clips, dev->clips_cap,
+ clipcount * sizeof(dev->clips_cap[0]));
return 0;
}
@@ -1141,9 +1139,8 @@ int vidioc_try_fmt_vid_overlay(struct file *file, void *priv,
if (win->clipcount > MAX_CLIPS)
win->clipcount = MAX_CLIPS;
if (win->clipcount) {
- if (copy_from_user(dev->try_clips_cap, win->clips,
- win->clipcount * sizeof(dev->clips_cap[0])))
- return -EFAULT;
+ memcpy(dev->try_clips_cap, win->clips,
+ win->clipcount * sizeof(dev->clips_cap[0]));
for (i = 0; i < win->clipcount; i++) {
struct v4l2_rect *r = &dev->try_clips_cap[i].c;
@@ -1166,9 +1163,8 @@ int vidioc_try_fmt_vid_overlay(struct file *file, void *priv,
return -EINVAL;
}
}
- if (copy_to_user(win->clips, dev->try_clips_cap,
- win->clipcount * sizeof(dev->clips_cap[0])))
- return -EFAULT;
+ memcpy(win->clips, dev->try_clips_cap,
+ win->clipcount * sizeof(dev->clips_cap[0]));
}
return 0;
}
diff --git a/drivers/media/test-drivers/vivid/vivid-vid-out.c b/drivers/media/test-drivers/vivid/vivid-vid-out.c
index ee3446e3217c..ac1e981e8342 100644
--- a/drivers/media/test-drivers/vivid/vivid-vid-out.c
+++ b/drivers/media/test-drivers/vivid/vivid-vid-out.c
@@ -857,11 +857,9 @@ int vidioc_g_fmt_vid_out_overlay(struct file *file, void *priv,
((dev->compose_out.width + 7) / 8) * dev->compose_out.height))
return -EFAULT;
}
- if (clipcount && win->clips) {
- if (copy_to_user(win->clips, dev->clips_out,
- clipcount * sizeof(dev->clips_out[0])))
- return -EFAULT;
- }
+ if (clipcount && win->clips)
+ memcpy(win->clips, dev->clips_out,
+ clipcount * sizeof(dev->clips_out[0]));
return 0;
}
@@ -891,9 +889,8 @@ int vidioc_try_fmt_vid_out_overlay(struct file *file, void *priv,
if (win->clipcount > MAX_CLIPS)
win->clipcount = MAX_CLIPS;
if (win->clipcount) {
- if (copy_from_user(dev->try_clips_out, win->clips,
- win->clipcount * sizeof(dev->clips_out[0])))
- return -EFAULT;
+ memcpy(dev->try_clips_out, win->clips,
+ win->clipcount * sizeof(dev->clips_out[0]));
for (i = 0; i < win->clipcount; i++) {
struct v4l2_rect *r = &dev->try_clips_out[i].c;
@@ -916,9 +913,8 @@ int vidioc_try_fmt_vid_out_overlay(struct file *file, void *priv,
return -EINVAL;
}
}
- if (copy_to_user(win->clips, dev->try_clips_out,
- win->clipcount * sizeof(dev->clips_out[0])))
- return -EFAULT;
+ memcpy(win->clips, dev->try_clips_out,
+ win->clipcount * sizeof(dev->clips_out[0]));
}
return 0;
}