Merge "video: driver: add RGBA format support"
This commit is contained in:

committed by
Gerrit - the friendly Code Review server

commit
c07fa5dd60
@@ -111,13 +111,15 @@ static struct msm_platform_inst_capability instance_data_waipio[] = {
|
|||||||
{PIX_FMTS, ENC, H264,
|
{PIX_FMTS, ENC, H264,
|
||||||
MSM_VIDC_FMT_NV12,
|
MSM_VIDC_FMT_NV12,
|
||||||
MSM_VIDC_FMT_NV12C,
|
MSM_VIDC_FMT_NV12C,
|
||||||
MSM_VIDC_FMT_NV12 | MSM_VIDC_FMT_NV21 | MSM_VIDC_FMT_NV12C,
|
MSM_VIDC_FMT_NV12 | MSM_VIDC_FMT_NV21 | MSM_VIDC_FMT_NV12C |
|
||||||
|
MSM_VIDC_FMT_RGBA8888 | MSM_VIDC_FMT_RGBA8888C,
|
||||||
MSM_VIDC_FMT_NV12C},
|
MSM_VIDC_FMT_NV12C},
|
||||||
{PIX_FMTS, ENC, HEVC|HEIC,
|
{PIX_FMTS, ENC, HEVC|HEIC,
|
||||||
MSM_VIDC_FMT_NV12,
|
MSM_VIDC_FMT_NV12,
|
||||||
MSM_VIDC_FMT_TP10C,
|
MSM_VIDC_FMT_TP10C,
|
||||||
MSM_VIDC_FMT_NV12 | MSM_VIDC_FMT_NV21 | MSM_VIDC_FMT_NV12C |
|
MSM_VIDC_FMT_NV12 | MSM_VIDC_FMT_NV21 | MSM_VIDC_FMT_NV12C |
|
||||||
MSM_VIDC_FMT_P010 | MSM_VIDC_FMT_TP10C,
|
MSM_VIDC_FMT_P010 | MSM_VIDC_FMT_TP10C |
|
||||||
|
MSM_VIDC_FMT_RGBA8888 | MSM_VIDC_FMT_RGBA8888C,
|
||||||
MSM_VIDC_FMT_NV12C,
|
MSM_VIDC_FMT_NV12C,
|
||||||
0, 0,
|
0, 0,
|
||||||
CAP_FLAG_ROOT,
|
CAP_FLAG_ROOT,
|
||||||
|
@@ -384,7 +384,8 @@ static inline unsigned int VIDEO_RGB_STRIDE_BYTES(unsigned int v4l2_fmt,
|
|||||||
|
|
||||||
switch (v4l2_fmt) {
|
switch (v4l2_fmt) {
|
||||||
case V4L2_PIX_FMT_VIDC_ARGB32C:
|
case V4L2_PIX_FMT_VIDC_ARGB32C:
|
||||||
alignment = 64;
|
case V4L2_PIX_FMT_RGBA32:
|
||||||
|
alignment = 256;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
goto invalid_input;
|
goto invalid_input;
|
||||||
@@ -414,6 +415,7 @@ static inline unsigned int VIDEO_RGB_SCANLINES(unsigned int v4l2_fmt,
|
|||||||
|
|
||||||
switch (v4l2_fmt) {
|
switch (v4l2_fmt) {
|
||||||
case V4L2_PIX_FMT_VIDC_ARGB32C:
|
case V4L2_PIX_FMT_VIDC_ARGB32C:
|
||||||
|
case V4L2_PIX_FMT_RGBA32:
|
||||||
alignment = 16;
|
alignment = 16;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -436,6 +438,7 @@ static inline unsigned int VIDEO_RGB_META_STRIDE(unsigned int v4l2_fmt,
|
|||||||
|
|
||||||
switch (v4l2_fmt) {
|
switch (v4l2_fmt) {
|
||||||
case V4L2_PIX_FMT_VIDC_ARGB32C:
|
case V4L2_PIX_FMT_VIDC_ARGB32C:
|
||||||
|
case V4L2_PIX_FMT_RGBA32:
|
||||||
rgb_tile_width = 16;
|
rgb_tile_width = 16;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -459,6 +462,7 @@ static inline unsigned int VIDEO_RGB_META_SCANLINES(unsigned int v4l2_fmt,
|
|||||||
|
|
||||||
switch (v4l2_fmt) {
|
switch (v4l2_fmt) {
|
||||||
case V4L2_PIX_FMT_VIDC_ARGB32C:
|
case V4L2_PIX_FMT_VIDC_ARGB32C:
|
||||||
|
case V4L2_PIX_FMT_RGBA32:
|
||||||
rgb_tile_height = 4;
|
rgb_tile_height = 4;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -483,7 +487,7 @@ static inline unsigned int VIDEO_RAW_BUFFER_SIZE(unsigned int v4l2_fmt,
|
|||||||
unsigned int uv_meta_stride = 0, uv_meta_scanlines = 0;
|
unsigned int uv_meta_stride = 0, uv_meta_scanlines = 0;
|
||||||
unsigned int y_meta_plane = 0, uv_meta_plane = 0;
|
unsigned int y_meta_plane = 0, uv_meta_plane = 0;
|
||||||
unsigned int rgb_stride = 0, rgb_scanlines = 0;
|
unsigned int rgb_stride = 0, rgb_scanlines = 0;
|
||||||
unsigned int rgb_ubwc_plane = 0, rgb_meta_plane = 0;
|
unsigned int rgb_plane = 0, rgb_ubwc_plane = 0, rgb_meta_plane = 0;
|
||||||
unsigned int rgb_meta_stride = 0, rgb_meta_scanlines = 0;
|
unsigned int rgb_meta_stride = 0, rgb_meta_scanlines = 0;
|
||||||
|
|
||||||
if (!pix_width || !pix_height)
|
if (!pix_width || !pix_height)
|
||||||
@@ -588,6 +592,10 @@ static inline unsigned int VIDEO_RAW_BUFFER_SIZE(unsigned int v4l2_fmt,
|
|||||||
rgb_meta_scanlines, 4096);
|
rgb_meta_scanlines, 4096);
|
||||||
size = rgb_ubwc_plane + rgb_meta_plane;
|
size = rgb_ubwc_plane + rgb_meta_plane;
|
||||||
break;
|
break;
|
||||||
|
case V4L2_PIX_FMT_RGBA32:
|
||||||
|
rgb_plane = MSM_MEDIA_ALIGN(rgb_stride * rgb_scanlines, 4096);
|
||||||
|
size = rgb_plane;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -156,6 +156,12 @@ static inline bool is_8bit_colorformat(enum msm_vidc_colorformat_type colorforma
|
|||||||
colorformat == MSM_VIDC_FMT_RGBA8888C;
|
colorformat == MSM_VIDC_FMT_RGBA8888C;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool is_rgba_colorformat(enum msm_vidc_colorformat_type colorformat)
|
||||||
|
{
|
||||||
|
return colorformat == MSM_VIDC_FMT_RGBA8888 ||
|
||||||
|
colorformat == MSM_VIDC_FMT_RGBA8888C;
|
||||||
|
}
|
||||||
|
|
||||||
static inline bool is_secondary_output_mode(struct msm_vidc_inst *inst)
|
static inline bool is_secondary_output_mode(struct msm_vidc_inst *inst)
|
||||||
{
|
{
|
||||||
return false; // TODO: inst->stream_output_mode == HAL_VIDEO_DECODER_SECONDARY;
|
return false; // TODO: inst->stream_output_mode == HAL_VIDEO_DECODER_SECONDARY;
|
||||||
|
@@ -127,7 +127,8 @@ static int msm_venc_set_stride_scanline(struct msm_vidc_inst *inst,
|
|||||||
enum msm_vidc_port_type port)
|
enum msm_vidc_port_type port)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
u32 pixelformat, stride_y, scanline_y, stride_uv, scanline_uv;
|
u32 color_format, stride_y, scanline_y;
|
||||||
|
u32 stride_uv = 0, scanline_uv = 0;
|
||||||
u32 payload[2];
|
u32 payload[2];
|
||||||
|
|
||||||
if (port != INPUT_PORT) {
|
if (port != INPUT_PORT) {
|
||||||
@@ -135,9 +136,8 @@ static int msm_venc_set_stride_scanline(struct msm_vidc_inst *inst,
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pixelformat = inst->fmts[INPUT_PORT].fmt.pix_mp.pixelformat;
|
color_format = inst->capabilities->cap[PIX_FMTS].value;
|
||||||
if (pixelformat != V4L2_PIX_FMT_NV12 &&
|
if (!is_linear_colorformat(color_format)) {
|
||||||
pixelformat != V4L2_PIX_FMT_VIDC_P010) {
|
|
||||||
i_vpr_e(inst,
|
i_vpr_e(inst,
|
||||||
"%s: not a linear color fmt, property is not set\n",
|
"%s: not a linear color fmt, property is not set\n",
|
||||||
__func__);
|
__func__);
|
||||||
@@ -146,8 +146,11 @@ static int msm_venc_set_stride_scanline(struct msm_vidc_inst *inst,
|
|||||||
|
|
||||||
stride_y = inst->fmts[INPUT_PORT].fmt.pix_mp.width;
|
stride_y = inst->fmts[INPUT_PORT].fmt.pix_mp.width;
|
||||||
scanline_y = inst->fmts[INPUT_PORT].fmt.pix_mp.height;
|
scanline_y = inst->fmts[INPUT_PORT].fmt.pix_mp.height;
|
||||||
|
if (color_format == MSM_VIDC_FMT_NV12 ||
|
||||||
|
color_format == MSM_VIDC_FMT_P010) {
|
||||||
stride_uv = stride_y;
|
stride_uv = stride_y;
|
||||||
scanline_uv = scanline_y / 2;
|
scanline_uv = scanline_y / 2;
|
||||||
|
}
|
||||||
|
|
||||||
payload[0] = stride_y << 16 | scanline_y;
|
payload[0] = stride_y << 16 | scanline_y;
|
||||||
payload[1] = stride_uv << 16 | scanline_uv;
|
payload[1] = stride_uv << 16 | scanline_uv;
|
||||||
@@ -1192,6 +1195,7 @@ static int msm_venc_s_fmt_input(struct msm_vidc_inst *inst, struct v4l2_format *
|
|||||||
struct v4l2_format *fmt;
|
struct v4l2_format *fmt;
|
||||||
struct msm_vidc_core *core;
|
struct msm_vidc_core *core;
|
||||||
u32 pix_fmt;
|
u32 pix_fmt;
|
||||||
|
u32 crop_width, crop_height;
|
||||||
|
|
||||||
if (!inst || !inst->core || !inst->capabilities) {
|
if (!inst || !inst->core || !inst->capabilities) {
|
||||||
d_vpr_e("%s: invalid params\n", __func__);
|
d_vpr_e("%s: invalid params\n", __func__);
|
||||||
@@ -1204,15 +1208,33 @@ static int msm_venc_s_fmt_input(struct msm_vidc_inst *inst, struct v4l2_format *
|
|||||||
fmt->fmt.pix_mp.pixelformat = f->fmt.pix_mp.pixelformat;
|
fmt->fmt.pix_mp.pixelformat = f->fmt.pix_mp.pixelformat;
|
||||||
pix_fmt = v4l2_colorformat_to_driver(f->fmt.pix_mp.pixelformat, __func__);
|
pix_fmt = v4l2_colorformat_to_driver(f->fmt.pix_mp.pixelformat, __func__);
|
||||||
msm_vidc_update_cap_value(inst, PIX_FMTS, pix_fmt, __func__);
|
msm_vidc_update_cap_value(inst, PIX_FMTS, pix_fmt, __func__);
|
||||||
|
if (is_rgba_colorformat(pix_fmt)) {
|
||||||
|
fmt->fmt.pix_mp.width = VIDEO_RGB_STRIDE_PIX(fmt->fmt.pix_mp.pixelformat,
|
||||||
|
f->fmt.pix_mp.width);
|
||||||
|
fmt->fmt.pix_mp.height = VIDEO_RGB_SCANLINES(fmt->fmt.pix_mp.pixelformat,
|
||||||
|
f->fmt.pix_mp.height);
|
||||||
|
fmt->fmt.pix_mp.plane_fmt[0].bytesperline =
|
||||||
|
VIDEO_RGB_STRIDE_BYTES(fmt->fmt.pix_mp.pixelformat,
|
||||||
|
f->fmt.pix_mp.width);
|
||||||
|
crop_width = VIDEO_RGB_STRIDE_PIX(
|
||||||
|
fmt->fmt.pix_mp.pixelformat, inst->crop.width);
|
||||||
|
crop_height = VIDEO_RGB_SCANLINES(
|
||||||
|
fmt->fmt.pix_mp.pixelformat, inst->crop.height);
|
||||||
|
} else {
|
||||||
fmt->fmt.pix_mp.width = VIDEO_Y_STRIDE_PIX(fmt->fmt.pix_mp.pixelformat,
|
fmt->fmt.pix_mp.width = VIDEO_Y_STRIDE_PIX(fmt->fmt.pix_mp.pixelformat,
|
||||||
f->fmt.pix_mp.width);
|
f->fmt.pix_mp.width);
|
||||||
fmt->fmt.pix_mp.height = VIDEO_Y_SCANLINES(fmt->fmt.pix_mp.pixelformat,
|
fmt->fmt.pix_mp.height = VIDEO_Y_SCANLINES(fmt->fmt.pix_mp.pixelformat,
|
||||||
f->fmt.pix_mp.height);
|
f->fmt.pix_mp.height);
|
||||||
|
|
||||||
fmt->fmt.pix_mp.num_planes = 1;
|
|
||||||
fmt->fmt.pix_mp.plane_fmt[0].bytesperline =
|
fmt->fmt.pix_mp.plane_fmt[0].bytesperline =
|
||||||
VIDEO_Y_STRIDE_BYTES(fmt->fmt.pix_mp.pixelformat,
|
VIDEO_Y_STRIDE_BYTES(fmt->fmt.pix_mp.pixelformat,
|
||||||
f->fmt.pix_mp.width);
|
f->fmt.pix_mp.width);
|
||||||
|
crop_width = VIDEO_Y_STRIDE_PIX(
|
||||||
|
fmt->fmt.pix_mp.pixelformat, inst->crop.width);
|
||||||
|
crop_height = VIDEO_Y_SCANLINES(
|
||||||
|
fmt->fmt.pix_mp.pixelformat, inst->crop.height);
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt->fmt.pix_mp.num_planes = 1;
|
||||||
fmt->fmt.pix_mp.plane_fmt[0].sizeimage = call_session_op(core,
|
fmt->fmt.pix_mp.plane_fmt[0].sizeimage = call_session_op(core,
|
||||||
buffer_size, inst, MSM_VIDC_BUF_INPUT);
|
buffer_size, inst, MSM_VIDC_BUF_INPUT);
|
||||||
fmt->fmt.pix_mp.colorspace = f->fmt.pix_mp.colorspace;
|
fmt->fmt.pix_mp.colorspace = f->fmt.pix_mp.colorspace;
|
||||||
@@ -1233,10 +1255,8 @@ static int msm_venc_s_fmt_input(struct msm_vidc_inst *inst, struct v4l2_format *
|
|||||||
inst->buffers.input.size =
|
inst->buffers.input.size =
|
||||||
fmt->fmt.pix_mp.plane_fmt[0].sizeimage;
|
fmt->fmt.pix_mp.plane_fmt[0].sizeimage;
|
||||||
|
|
||||||
if (fmt->fmt.pix_mp.width != VIDEO_Y_STRIDE_PIX(
|
if (fmt->fmt.pix_mp.width != crop_width ||
|
||||||
fmt->fmt.pix_mp.pixelformat, inst->crop.width) ||
|
fmt->fmt.pix_mp.height != crop_height) {
|
||||||
fmt->fmt.pix_mp.height != VIDEO_Y_SCANLINES(
|
|
||||||
fmt->fmt.pix_mp.pixelformat, inst->crop.height)) {
|
|
||||||
|
|
||||||
/* reset crop dimensions with updated resolution */
|
/* reset crop dimensions with updated resolution */
|
||||||
inst->crop.top = inst->crop.left = 0;
|
inst->crop.top = inst->crop.left = 0;
|
||||||
|
@@ -423,6 +423,9 @@ enum msm_vidc_colorformat_type v4l2_colorformat_to_driver(u32 v4l2_colorformat,
|
|||||||
case V4L2_PIX_FMT_VIDC_TP10C:
|
case V4L2_PIX_FMT_VIDC_TP10C:
|
||||||
colorformat = MSM_VIDC_FMT_TP10C;
|
colorformat = MSM_VIDC_FMT_TP10C;
|
||||||
break;
|
break;
|
||||||
|
case V4L2_PIX_FMT_RGBA32:
|
||||||
|
colorformat = MSM_VIDC_FMT_RGBA8888;
|
||||||
|
break;
|
||||||
case V4L2_PIX_FMT_VIDC_ARGB32C:
|
case V4L2_PIX_FMT_VIDC_ARGB32C:
|
||||||
colorformat = MSM_VIDC_FMT_RGBA8888C;
|
colorformat = MSM_VIDC_FMT_RGBA8888C;
|
||||||
break;
|
break;
|
||||||
@@ -455,6 +458,9 @@ u32 v4l2_colorformat_from_driver(enum msm_vidc_colorformat_type colorformat,
|
|||||||
case MSM_VIDC_FMT_TP10C:
|
case MSM_VIDC_FMT_TP10C:
|
||||||
v4l2_colorformat = V4L2_PIX_FMT_VIDC_TP10C;
|
v4l2_colorformat = V4L2_PIX_FMT_VIDC_TP10C;
|
||||||
break;
|
break;
|
||||||
|
case MSM_VIDC_FMT_RGBA8888:
|
||||||
|
v4l2_colorformat = V4L2_PIX_FMT_RGBA32;
|
||||||
|
break;
|
||||||
case MSM_VIDC_FMT_RGBA8888C:
|
case MSM_VIDC_FMT_RGBA8888C:
|
||||||
v4l2_colorformat = V4L2_PIX_FMT_VIDC_ARGB32C;
|
v4l2_colorformat = V4L2_PIX_FMT_VIDC_ARGB32C;
|
||||||
break;
|
break;
|
||||||
|
@@ -12,8 +12,7 @@
|
|||||||
/*
|
/*
|
||||||
* supported standard color formats
|
* supported standard color formats
|
||||||
* V4L2_PIX_FMT_NV12 Y/CbCr 4:2:0
|
* V4L2_PIX_FMT_NV12 Y/CbCr 4:2:0
|
||||||
* NV21?? // TODO: jdas
|
* V4L2_PIX_FMT_RGBA32 RGBA-8-8-8-8
|
||||||
* V4L2_PIX_FMT_ARGB32 ARGB-8-8-8-8
|
|
||||||
*/
|
*/
|
||||||
/* Below are additional color formats */
|
/* Below are additional color formats */
|
||||||
/* 12 Y/CbCr 4:2:0 compressed */
|
/* 12 Y/CbCr 4:2:0 compressed */
|
||||||
@@ -22,7 +21,7 @@
|
|||||||
#define V4L2_PIX_FMT_VIDC_TP10C v4l2_fourcc('Q', '1', '0', 'C')
|
#define V4L2_PIX_FMT_VIDC_TP10C v4l2_fourcc('Q', '1', '0', 'C')
|
||||||
/* Y/CbCr 4:2:0, 10 bits per channel */
|
/* Y/CbCr 4:2:0, 10 bits per channel */
|
||||||
#define V4L2_PIX_FMT_VIDC_P010 v4l2_fourcc('P', '0', '1', '0')
|
#define V4L2_PIX_FMT_VIDC_P010 v4l2_fourcc('P', '0', '1', '0')
|
||||||
/* 32 ARGB-8-8-8-8 compressed */
|
/* 32 RGBA-8-8-8-8 compressed */
|
||||||
#define V4L2_PIX_FMT_VIDC_ARGB32C v4l2_fourcc('Q', '2', '4', 'C')
|
#define V4L2_PIX_FMT_VIDC_ARGB32C v4l2_fourcc('Q', '2', '4', 'C')
|
||||||
#define V4L2_META_FMT_VIDC v4l2_fourcc('Q', 'M', 'E', 'T')
|
#define V4L2_META_FMT_VIDC v4l2_fourcc('Q', 'M', 'E', 'T')
|
||||||
/* HEIC encoder and decoder */
|
/* HEIC encoder and decoder */
|
||||||
|
Reference in New Issue
Block a user