Merge "msm: vidc: Decide plane count whenever extradata is set"

This commit is contained in:
Linux Build Service Account 2017-02-15 06:11:16 -08:00 committed by Gerrit - the friendly Code Review server
commit 9d77f1dc26
6 changed files with 107 additions and 146 deletions

View file

@ -704,7 +704,6 @@ struct msm_vidc_format vdec_formats[] = {
.name = "YCbCr Semiplanar 4:2:0",
.description = "Y/CbCr 4:2:0",
.fourcc = V4L2_PIX_FMT_NV12,
.num_planes = 2,
.get_frame_size = get_frame_size_nv12,
.type = CAPTURE_PORT,
},
@ -712,7 +711,6 @@ struct msm_vidc_format vdec_formats[] = {
.name = "UBWC YCbCr Semiplanar 4:2:0",
.description = "UBWC Y/CbCr 4:2:0",
.fourcc = V4L2_PIX_FMT_NV12_UBWC,
.num_planes = 2,
.get_frame_size = get_frame_size_nv12_ubwc,
.type = CAPTURE_PORT,
},
@ -720,7 +718,6 @@ struct msm_vidc_format vdec_formats[] = {
.name = "UBWC YCbCr Semiplanar 4:2:0 10bit",
.description = "UBWC Y/CbCr 4:2:0 10bit",
.fourcc = V4L2_PIX_FMT_NV12_TP10_UBWC,
.num_planes = 2,
.get_frame_size = get_frame_size_nv12_ubwc_10bit,
.type = CAPTURE_PORT,
},
@ -728,7 +725,6 @@ struct msm_vidc_format vdec_formats[] = {
.name = "Mpeg4",
.description = "Mpeg4 compressed format",
.fourcc = V4L2_PIX_FMT_MPEG4,
.num_planes = 1,
.get_frame_size = get_frame_size_compressed,
.type = OUTPUT_PORT,
},
@ -736,7 +732,6 @@ struct msm_vidc_format vdec_formats[] = {
.name = "Mpeg2",
.description = "Mpeg2 compressed format",
.fourcc = V4L2_PIX_FMT_MPEG2,
.num_planes = 1,
.get_frame_size = get_frame_size_compressed,
.type = OUTPUT_PORT,
},
@ -744,7 +739,6 @@ struct msm_vidc_format vdec_formats[] = {
.name = "H263",
.description = "H263 compressed format",
.fourcc = V4L2_PIX_FMT_H263,
.num_planes = 1,
.get_frame_size = get_frame_size_compressed,
.type = OUTPUT_PORT,
},
@ -752,7 +746,6 @@ struct msm_vidc_format vdec_formats[] = {
.name = "VC1",
.description = "VC-1 compressed format",
.fourcc = V4L2_PIX_FMT_VC1_ANNEX_G,
.num_planes = 1,
.get_frame_size = get_frame_size_compressed,
.type = OUTPUT_PORT,
},
@ -760,7 +753,6 @@ struct msm_vidc_format vdec_formats[] = {
.name = "VC1 SP",
.description = "VC-1 compressed format G",
.fourcc = V4L2_PIX_FMT_VC1_ANNEX_L,
.num_planes = 1,
.get_frame_size = get_frame_size_compressed,
.type = OUTPUT_PORT,
},
@ -768,7 +760,6 @@ struct msm_vidc_format vdec_formats[] = {
.name = "H264",
.description = "H264 compressed format",
.fourcc = V4L2_PIX_FMT_H264,
.num_planes = 1,
.get_frame_size = get_frame_size_compressed,
.type = OUTPUT_PORT,
},
@ -776,7 +767,6 @@ struct msm_vidc_format vdec_formats[] = {
.name = "H264_MVC",
.description = "H264_MVC compressed format",
.fourcc = V4L2_PIX_FMT_H264_MVC,
.num_planes = 1,
.get_frame_size = get_frame_size_compressed,
.type = OUTPUT_PORT,
},
@ -784,7 +774,6 @@ struct msm_vidc_format vdec_formats[] = {
.name = "HEVC",
.description = "HEVC compressed format",
.fourcc = V4L2_PIX_FMT_HEVC,
.num_planes = 1,
.get_frame_size = get_frame_size_compressed,
.type = OUTPUT_PORT,
},
@ -792,7 +781,6 @@ struct msm_vidc_format vdec_formats[] = {
.name = "HEVC_HYBRID",
.description = "HEVC compressed format",
.fourcc = V4L2_PIX_FMT_HEVC_HYBRID,
.num_planes = 1,
.get_frame_size = get_frame_size_compressed,
.type = OUTPUT_PORT,
},
@ -800,7 +788,6 @@ struct msm_vidc_format vdec_formats[] = {
.name = "VP8",
.description = "VP8 compressed format",
.fourcc = V4L2_PIX_FMT_VP8,
.num_planes = 1,
.get_frame_size = get_frame_size_compressed,
.type = OUTPUT_PORT,
},
@ -808,7 +795,6 @@ struct msm_vidc_format vdec_formats[] = {
.name = "VP9",
.description = "VP9 compressed format",
.fourcc = V4L2_PIX_FMT_VP9,
.num_planes = 1,
.get_frame_size = get_frame_size_compressed_full_yuv,
.type = OUTPUT_PORT,
},
@ -816,7 +802,6 @@ struct msm_vidc_format vdec_formats[] = {
.name = "DIVX 311",
.description = "DIVX 311 compressed format",
.fourcc = V4L2_PIX_FMT_DIVX_311,
.num_planes = 1,
.get_frame_size = get_frame_size_compressed,
.type = OUTPUT_PORT,
},
@ -824,7 +809,6 @@ struct msm_vidc_format vdec_formats[] = {
.name = "DIVX",
.description = "DIVX 4/5/6 compressed format",
.fourcc = V4L2_PIX_FMT_DIVX,
.num_planes = 1,
.get_frame_size = get_frame_size_compressed,
.type = OUTPUT_PORT,
}
@ -896,10 +880,10 @@ int msm_vdec_prepare_buf(struct msm_vidc_inst *inst,
case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
break;
case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
if (b->length != inst->fmts[CAPTURE_PORT].num_planes) {
if (b->length != inst->prop.num_planes[CAPTURE_PORT]) {
dprintk(VIDC_ERR,
"Planes mismatch: needed: %d, allocated: %d\n",
inst->fmts[CAPTURE_PORT].num_planes,
inst->prop.num_planes[CAPTURE_PORT],
b->length);
rc = -EINVAL;
break;
@ -975,10 +959,10 @@ int msm_vdec_release_buf(struct msm_vidc_inst *inst,
case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
break;
case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
if (b->length != inst->fmts[CAPTURE_PORT].num_planes) {
if (b->length != inst->prop.num_planes[CAPTURE_PORT]) {
dprintk(VIDC_ERR,
"Planes mismatch: needed: %d, to release: %d\n",
inst->fmts[CAPTURE_PORT].num_planes, b->length);
inst->prop.num_planes[CAPTURE_PORT], b->length);
rc = -EINVAL;
break;
}
@ -1090,6 +1074,7 @@ int msm_vdec_g_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
struct hfi_device *hdev;
int rc = 0, i = 0, stride = 0, scanlines = 0, color_format = 0;
unsigned int *plane_sizes = NULL, extra_idx = 0;
int num_planes = 0;
if (!inst || !f || !inst->core || !inst->core->device) {
dprintk(VIDC_ERR,
@ -1106,7 +1091,9 @@ int msm_vdec_g_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
return -ENOTSUPP;
f->fmt.pix_mp.pixelformat = fmt->fourcc;
f->fmt.pix_mp.num_planes = fmt->num_planes;
f->fmt.pix_mp.num_planes = inst->prop.num_planes[fmt->type];
num_planes = inst->prop.num_planes[fmt->type];
if (inst->in_reconfig) {
inst->prop.height[OUTPUT_PORT] = inst->reconfig_height;
inst->prop.width[OUTPUT_PORT] = inst->reconfig_width;
@ -1126,7 +1113,7 @@ int msm_vdec_g_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
plane_sizes = &inst->bufq[OUTPUT_PORT].vb2_bufq.plane_sizes[0];
for (i = 0; i < fmt->num_planes; ++i) {
for (i = 0; i < num_planes; ++i) {
if (!plane_sizes[i]) {
f->fmt.pix_mp.plane_fmt[i].sizeimage =
get_frame_size(inst, fmt, f->type, i);
@ -1169,7 +1156,7 @@ int msm_vdec_g_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
inst->prop.height[CAPTURE_PORT],
inst->prop.width[CAPTURE_PORT]);
extra_idx = EXTRADATA_IDX(fmt->num_planes);
extra_idx = EXTRADATA_IDX(num_planes);
if (extra_idx && extra_idx < VIDEO_MAX_PLANES) {
f->fmt.pix_mp.plane_fmt[extra_idx].sizeimage =
VENUS_EXTRADATA_SIZE(
@ -1177,7 +1164,7 @@ int msm_vdec_g_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
inst->prop.width[CAPTURE_PORT]);
}
for (i = 0; i < fmt->num_planes; ++i)
for (i = 0; i < num_planes; ++i)
inst->bufq[CAPTURE_PORT].vb2_bufq.plane_sizes[i] =
f->fmt.pix_mp.plane_fmt[i].sizeimage;
@ -1276,7 +1263,7 @@ int msm_vdec_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
inst->fmts[fmt->type].get_frame_size(0,
f->fmt.pix_mp.height, f->fmt.pix_mp.width);
extra_idx = EXTRADATA_IDX(inst->fmts[fmt->type].num_planes);
extra_idx = EXTRADATA_IDX(inst->prop.num_planes[fmt->type]);
if (extra_idx && extra_idx < VIDEO_MAX_PLANES) {
f->fmt.pix_mp.plane_fmt[extra_idx].sizeimage =
VENUS_EXTRADATA_SIZE(
@ -1284,8 +1271,8 @@ int msm_vdec_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
inst->prop.width[CAPTURE_PORT]);
}
f->fmt.pix_mp.num_planes = inst->fmts[fmt->type].num_planes;
for (i = 0; i < inst->fmts[fmt->type].num_planes; ++i) {
f->fmt.pix_mp.num_planes = inst->prop.num_planes[fmt->type];
for (i = 0; i < inst->prop.num_planes[fmt->type]; ++i) {
inst->bufq[CAPTURE_PORT].vb2_bufq.plane_sizes[i] =
f->fmt.pix_mp.plane_fmt[i].sizeimage;
}
@ -1346,14 +1333,14 @@ int msm_vdec_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
msm_comm_try_set_prop(inst, HAL_PARAM_FRAME_SIZE, &frame_sz);
max_input_size = get_frame_size(
inst, &inst->fmts[fmt->type], f->type, 0);
inst, &inst->fmts[fmt->type], f->type, 0);
if (f->fmt.pix_mp.plane_fmt[0].sizeimage > max_input_size ||
!f->fmt.pix_mp.plane_fmt[0].sizeimage) {
f->fmt.pix_mp.plane_fmt[0].sizeimage = max_input_size;
}
f->fmt.pix_mp.num_planes = inst->fmts[fmt->type].num_planes;
for (i = 0; i < inst->fmts[fmt->type].num_planes; ++i) {
f->fmt.pix_mp.num_planes = inst->prop.num_planes[fmt->type];
for (i = 0; i < inst->prop.num_planes[fmt->type]; ++i) {
inst->bufq[OUTPUT_PORT].vb2_bufq.plane_sizes[i] =
f->fmt.pix_mp.plane_fmt[i].sizeimage;
}
@ -1467,7 +1454,7 @@ static int msm_vdec_queue_setup(struct vb2_queue *q,
switch (q->type) {
case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
*num_planes = inst->fmts[OUTPUT_PORT].num_planes;
*num_planes = inst->prop.num_planes[OUTPUT_PORT];
if (*num_buffers < MIN_NUM_OUTPUT_BUFFERS ||
*num_buffers > MAX_NUM_OUTPUT_BUFFERS)
*num_buffers = MIN_NUM_OUTPUT_BUFFERS;
@ -1480,7 +1467,7 @@ static int msm_vdec_queue_setup(struct vb2_queue *q,
break;
case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
dprintk(VIDC_DBG, "Getting bufreqs on capture plane\n");
*num_planes = inst->fmts[CAPTURE_PORT].num_planes;
*num_planes = inst->prop.num_planes[CAPTURE_PORT];
rc = msm_comm_try_state(inst, MSM_VIDC_OPEN_DONE);
if (rc) {
dprintk(VIDC_ERR, "Failed to open instance\n");
@ -1564,8 +1551,7 @@ static int msm_vdec_queue_setup(struct vb2_queue *q,
break;
}
extra_idx =
EXTRADATA_IDX(inst->fmts[CAPTURE_PORT].num_planes);
extra_idx = EXTRADATA_IDX(*num_planes);
if (extra_idx && extra_idx < VIDEO_MAX_PLANES) {
sizes[extra_idx] =
VENUS_EXTRADATA_SIZE(
@ -1944,8 +1930,14 @@ int msm_vdec_inst_init(struct msm_vidc_inst *inst)
}
inst->prop.height[CAPTURE_PORT] = DEFAULT_HEIGHT;
inst->prop.width[CAPTURE_PORT] = DEFAULT_WIDTH;
inst->prop.num_planes[CAPTURE_PORT] = 2;
inst->fmts[CAPTURE_PORT] = vdec_formats[0];
inst->prop.height[OUTPUT_PORT] = DEFAULT_HEIGHT;
inst->prop.width[OUTPUT_PORT] = DEFAULT_WIDTH;
inst->prop.num_planes[OUTPUT_PORT] = 1;
inst->fmts[OUTPUT_PORT] = vdec_formats[2];
inst->capability.height.min = MIN_SUPPORTED_HEIGHT;
inst->capability.height.max = DEFAULT_HEIGHT;
inst->capability.width.min = MIN_SUPPORTED_WIDTH;
@ -1958,10 +1950,6 @@ int msm_vdec_inst_init(struct msm_vidc_inst *inst)
inst->buffer_mode_set[CAPTURE_PORT] = HAL_BUFFER_MODE_STATIC;
inst->prop.fps = DEFAULT_FPS;
inst->operating_rate = 0;
memcpy(&inst->fmts[OUTPUT_PORT], &vdec_formats[2],
sizeof(struct msm_vidc_format));
memcpy(&inst->fmts[CAPTURE_PORT], &vdec_formats[0],
sizeof(struct msm_vidc_format));
return rc;
}

View file

@ -1343,7 +1343,6 @@ static struct msm_vidc_format venc_formats[] = {
.name = "YCbCr Semiplanar 4:2:0",
.description = "Y/CbCr 4:2:0",
.fourcc = V4L2_PIX_FMT_NV12,
.num_planes = 1,
.get_frame_size = get_frame_size_nv12,
.type = OUTPUT_PORT,
},
@ -1351,7 +1350,6 @@ static struct msm_vidc_format venc_formats[] = {
.name = "UBWC YCbCr Semiplanar 4:2:0",
.description = "UBWC Y/CbCr 4:2:0",
.fourcc = V4L2_PIX_FMT_NV12_UBWC,
.num_planes = 1,
.get_frame_size = get_frame_size_nv12_ubwc,
.type = OUTPUT_PORT,
},
@ -1359,7 +1357,6 @@ static struct msm_vidc_format venc_formats[] = {
.name = "RGBA 8:8:8:8",
.description = "RGBA 8:8:8:8",
.fourcc = V4L2_PIX_FMT_RGB32,
.num_planes = 1,
.get_frame_size = get_frame_size_rgba,
.type = OUTPUT_PORT,
},
@ -1367,7 +1364,6 @@ static struct msm_vidc_format venc_formats[] = {
.name = "UBWC RGBA 8:8:8:8",
.description = "UBWC RGBA 8:8:8:8",
.fourcc = V4L2_PIX_FMT_RGBA8888_UBWC,
.num_planes = 1,
.get_frame_size = get_frame_size_rgba_ubwc,
.type = OUTPUT_PORT,
},
@ -1375,7 +1371,6 @@ static struct msm_vidc_format venc_formats[] = {
.name = "Mpeg4",
.description = "Mpeg4 compressed format",
.fourcc = V4L2_PIX_FMT_MPEG4,
.num_planes = 1,
.get_frame_size = get_frame_size_compressed,
.type = CAPTURE_PORT,
},
@ -1383,7 +1378,6 @@ static struct msm_vidc_format venc_formats[] = {
.name = "H263",
.description = "H263 compressed format",
.fourcc = V4L2_PIX_FMT_H263,
.num_planes = 1,
.get_frame_size = get_frame_size_compressed,
.type = CAPTURE_PORT,
},
@ -1391,7 +1385,6 @@ static struct msm_vidc_format venc_formats[] = {
.name = "H264",
.description = "H264 compressed format",
.fourcc = V4L2_PIX_FMT_H264,
.num_planes = 1,
.get_frame_size = get_frame_size_compressed,
.type = CAPTURE_PORT,
},
@ -1399,7 +1392,6 @@ static struct msm_vidc_format venc_formats[] = {
.name = "VP8",
.description = "VP8 compressed format",
.fourcc = V4L2_PIX_FMT_VP8,
.num_planes = 1,
.get_frame_size = get_frame_size_compressed,
.type = CAPTURE_PORT,
},
@ -1407,7 +1399,6 @@ static struct msm_vidc_format venc_formats[] = {
.name = "HEVC",
.description = "HEVC compressed format",
.fourcc = V4L2_PIX_FMT_HEVC,
.num_planes = 1,
.get_frame_size = get_frame_size_compressed,
.type = CAPTURE_PORT,
},
@ -1415,57 +1406,71 @@ static struct msm_vidc_format venc_formats[] = {
.name = "YCrCb Semiplanar 4:2:0",
.description = "Y/CrCb 4:2:0",
.fourcc = V4L2_PIX_FMT_NV21,
.num_planes = 1,
.get_frame_size = get_frame_size_nv21,
.type = OUTPUT_PORT,
},
};
static void msm_venc_update_plane_count(struct msm_vidc_inst *inst, int type)
static int msm_venc_set_csc(struct msm_vidc_inst *inst)
{
struct v4l2_ctrl *ctrl = NULL;
u32 extradata = 0;
int rc = 0;
int count = 0;
struct hal_vpe_color_space_conversion vpe_csc;
while (count < HAL_MAX_MATRIX_COEFFS) {
if (count < HAL_MAX_BIAS_COEFFS)
vpe_csc.csc_bias[count] =
vpe_csc_601_to_709_bias_coeff[count];
if (count < HAL_MAX_LIMIT_COEFFS)
vpe_csc.csc_limit[count] =
vpe_csc_601_to_709_limit_coeff[count];
vpe_csc.csc_matrix[count] =
vpe_csc_601_to_709_matrix_coeff[count];
count = count + 1;
}
rc = msm_comm_try_set_prop(inst,
HAL_PARAM_VPE_COLOR_SPACE_CONVERSION, &vpe_csc);
if (rc)
dprintk(VIDC_ERR, "Setting VPE coefficients failed\n");
return rc;
}
static void msm_venc_register_extradata(
struct msm_vidc_inst *inst, u32 extradata) {
struct session_prop *prop = NULL;
if (!inst)
return;
inst->fmts[type].num_planes = 1;
ctrl = v4l2_ctrl_find(&inst->ctrl_handler,
V4L2_CID_MPEG_VIDC_VIDEO_EXTRADATA);
if (ctrl)
extradata = v4l2_ctrl_g_ctrl(ctrl);
if (type == CAPTURE_PORT) {
switch (extradata) {
prop = &inst->prop;
switch (extradata) {
case V4L2_MPEG_VIDC_EXTRADATA_MULTISLICE_INFO:
case V4L2_MPEG_VIDC_EXTRADATA_NUM_CONCEALED_MB:
case V4L2_MPEG_VIDC_EXTRADATA_METADATA_FILLER:
case V4L2_MPEG_VIDC_EXTRADATA_LTR:
case V4L2_MPEG_VIDC_EXTRADATA_METADATA_MBI:
inst->fmts[CAPTURE_PORT].num_planes = 2;
default:
prop->extradata[CAPTURE_PORT] |= extradata;
prop->num_planes[CAPTURE_PORT] = 2;
dprintk(VIDC_DBG, "Output Extradata: %#x",
prop->extradata[CAPTURE_PORT]);
break;
}
} else if (type == OUTPUT_PORT) {
switch (extradata) {
case V4L2_MPEG_VIDC_EXTRADATA_INPUT_CROP:
case V4L2_MPEG_VIDC_EXTRADATA_DIGITAL_ZOOM:
case V4L2_MPEG_VIDC_EXTRADATA_ASPECT_RATIO:
case V4L2_MPEG_VIDC_EXTRADATA_YUV_STATS:
case V4L2_MPEG_VIDC_EXTRADATA_ROI_QP:
case V4L2_MPEG_VIDC_EXTRADATA_PQ_INFO:
inst->fmts[OUTPUT_PORT].num_planes = 2;
prop->extradata[OUTPUT_PORT] |= extradata;
prop->num_planes[OUTPUT_PORT] = 2;
dprintk(VIDC_DBG, "Input Extradata: %#x",
prop->extradata[OUTPUT_PORT]);
break;
default:
break;
}
dprintk(VIDC_ERR, "Unknown extradata: %d", extradata);
}
}
static int msm_venc_set_csc(struct msm_vidc_inst *inst);
static int msm_venc_queue_setup(struct vb2_queue *q,
const void *parg,
unsigned int *num_buffers,
@ -1508,7 +1513,7 @@ static int msm_venc_queue_setup(struct vb2_queue *q,
switch (q->type) {
case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
*num_planes = 1;
*num_planes = inst->prop.num_planes[CAPTURE_PORT];
buff_req = get_buff_req_buffer(inst, HAL_BUFFER_OUTPUT);
if (buff_req) {
@ -1534,9 +1539,6 @@ static int msm_venc_queue_setup(struct vb2_queue *q,
temp, *num_buffers);
}
msm_venc_update_plane_count(inst, CAPTURE_PORT);
*num_planes = inst->fmts[CAPTURE_PORT].num_planes;
for (i = 0; i < *num_planes; i++) {
int extra_idx = EXTRADATA_IDX(*num_planes);
@ -1571,7 +1573,7 @@ static int msm_venc_queue_setup(struct vb2_queue *q,
break;
case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
*num_planes = 1;
*num_planes = inst->prop.num_planes[OUTPUT_PORT];
*num_buffers = inst->buff_req.buffer[0].buffer_count_actual =
max(*num_buffers, inst->buff_req.buffer[0].
@ -1593,9 +1595,6 @@ static int msm_venc_queue_setup(struct vb2_queue *q,
dprintk(VIDC_DBG, "actual input buffer count set to fw = %d\n",
*num_buffers);
msm_venc_update_plane_count(inst, OUTPUT_PORT);
*num_planes = inst->fmts[OUTPUT_PORT].num_planes;
rc = call_hfi_op(hdev, session_set_property, inst->session,
property_id, &new_buf_count);
if (rc)
@ -1610,7 +1609,7 @@ static int msm_venc_queue_setup(struct vb2_queue *q,
inst->prop.width[OUTPUT_PORT]);
extra_idx =
EXTRADATA_IDX(inst->fmts[OUTPUT_PORT].num_planes);
EXTRADATA_IDX(*num_planes);
if (extra_idx && (extra_idx < VIDEO_MAX_PLANES)) {
buff_req_buffer = get_buff_req_buffer(inst,
HAL_BUFFER_EXTRADATA_INPUT);
@ -2992,6 +2991,7 @@ static int try_set_ctrl(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl)
!!(inst->flags & VIDC_SECURE));
break;
case V4L2_CID_MPEG_VIDC_VIDEO_EXTRADATA:
msm_venc_register_extradata(inst, (u32)ctrl->val);
property_id = HAL_PARAM_INDEX_EXTRADATA;
extra.index = msm_comm_get_hal_extradata_index(ctrl->val);
extra.enable = 1;
@ -3633,8 +3633,14 @@ int msm_venc_inst_init(struct msm_vidc_inst *inst)
}
inst->prop.height[CAPTURE_PORT] = DEFAULT_HEIGHT;
inst->prop.width[CAPTURE_PORT] = DEFAULT_WIDTH;
inst->prop.num_planes[CAPTURE_PORT] = 1;
inst->fmts[CAPTURE_PORT] = venc_formats[4];
inst->prop.height[OUTPUT_PORT] = DEFAULT_HEIGHT;
inst->prop.width[OUTPUT_PORT] = DEFAULT_WIDTH;
inst->prop.num_planes[OUTPUT_PORT] = 1;
inst->fmts[OUTPUT_PORT] = venc_formats[0];
inst->capability.height.min = MIN_SUPPORTED_HEIGHT;
inst->capability.height.max = DEFAULT_HEIGHT;
inst->capability.width.min = MIN_SUPPORTED_WIDTH;
@ -3648,10 +3654,6 @@ int msm_venc_inst_init(struct msm_vidc_inst *inst)
inst->prop.fps = DEFAULT_FPS;
inst->capability.pixelprocess_capabilities = 0;
inst->operating_rate = 0;
memcpy(&inst->fmts[CAPTURE_PORT], &venc_formats[4],
sizeof(struct msm_vidc_format));
memcpy(&inst->fmts[OUTPUT_PORT], &venc_formats[0],
sizeof(struct msm_vidc_format));
return rc;
}
@ -3720,37 +3722,13 @@ int msm_venc_enum_fmt(struct msm_vidc_inst *inst, struct v4l2_fmtdesc *f)
return rc;
}
static int msm_venc_set_csc(struct msm_vidc_inst *inst)
{
int rc = 0;
int count = 0;
struct hal_vpe_color_space_conversion vpe_csc;
while (count < HAL_MAX_MATRIX_COEFFS) {
if (count < HAL_MAX_BIAS_COEFFS)
vpe_csc.csc_bias[count] =
vpe_csc_601_to_709_bias_coeff[count];
if (count < HAL_MAX_LIMIT_COEFFS)
vpe_csc.csc_limit[count] =
vpe_csc_601_to_709_limit_coeff[count];
vpe_csc.csc_matrix[count] =
vpe_csc_601_to_709_matrix_coeff[count];
count = count + 1;
}
rc = msm_comm_try_set_prop(inst,
HAL_PARAM_VPE_COLOR_SPACE_CONVERSION, &vpe_csc);
if (rc)
dprintk(VIDC_ERR, "Setting VPE coefficients failed\n");
return rc;
}
int msm_venc_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
{
struct msm_vidc_format *fmt = NULL;
int rc = 0;
int i;
int extra_idx = 0;
struct hfi_device *hdev;
if (!inst || !f) {
dprintk(VIDC_ERR,
"Invalid input, inst = %pK, format = %pK\n", inst, f);
@ -3777,9 +3755,7 @@ int msm_venc_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
memcpy(&inst->fmts[fmt->type], fmt,
sizeof(struct msm_vidc_format));
msm_venc_update_plane_count(inst, CAPTURE_PORT);
fmt->num_planes = inst->fmts[CAPTURE_PORT].num_planes;
f->fmt.pix_mp.num_planes = inst->prop.num_planes[CAPTURE_PORT];
rc = msm_comm_try_state(inst, MSM_VIDC_OPEN_DONE);
if (rc) {
@ -3833,10 +3809,7 @@ int msm_venc_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
}
memcpy(&inst->fmts[fmt->type], fmt,
sizeof(struct msm_vidc_format));
msm_venc_update_plane_count(inst, OUTPUT_PORT);
fmt->num_planes = inst->fmts[OUTPUT_PORT].num_planes;
f->fmt.pix_mp.num_planes = inst->prop.num_planes[OUTPUT_PORT];
msm_comm_set_color_format(inst, HAL_BUFFER_INPUT, fmt->fourcc);
} else {
dprintk(VIDC_ERR, "%s - Unsupported buf type: %d\n",
@ -3845,8 +3818,6 @@ int msm_venc_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
goto exit;
}
f->fmt.pix_mp.num_planes = fmt->num_planes;
if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
struct hal_frame_size frame_sz = {0};
struct hal_buffer_requirements *bufreq = NULL;
@ -3872,16 +3843,23 @@ int msm_venc_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
bufreq = get_buff_req_buffer(inst, HAL_BUFFER_OUTPUT);
f->fmt.pix_mp.plane_fmt[0].sizeimage =
bufreq ? bufreq->buffer_size : 0;
extra_idx = EXTRADATA_IDX(inst->prop.num_planes[fmt->type]);
if (extra_idx && (extra_idx < VIDEO_MAX_PLANES)) {
bufreq = get_buff_req_buffer(inst,
HAL_BUFFER_EXTRADATA_OUTPUT);
f->fmt.pix_mp.plane_fmt[extra_idx].sizeimage =
bufreq ? bufreq->buffer_size : 0;
}
} else if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
struct hal_buffer_requirements *bufreq = NULL;
int extra_idx = 0;
for (i = 0; i < inst->fmts[fmt->type].num_planes; ++i) {
f->fmt.pix_mp.plane_fmt[i].sizeimage =
inst->fmts[fmt->type].get_frame_size(i,
f->fmt.pix_mp.height, f->fmt.pix_mp.width);
}
extra_idx = EXTRADATA_IDX(inst->fmts[fmt->type].num_planes);
f->fmt.pix_mp.plane_fmt[0].sizeimage =
inst->fmts[fmt->type].get_frame_size(0,
f->fmt.pix_mp.height, f->fmt.pix_mp.width);
extra_idx = EXTRADATA_IDX(inst->prop.num_planes[fmt->type]);
if (extra_idx && (extra_idx < VIDEO_MAX_PLANES)) {
bufreq = get_buff_req_buffer(inst,
HAL_BUFFER_EXTRADATA_INPUT);
@ -3919,14 +3897,12 @@ int msm_venc_g_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
fmt = &inst->fmts[CAPTURE_PORT];
height = inst->prop.height[CAPTURE_PORT];
width = inst->prop.width[CAPTURE_PORT];
msm_venc_update_plane_count(inst, CAPTURE_PORT);
num_planes = inst->fmts[CAPTURE_PORT].num_planes;
num_planes = inst->prop.num_planes[CAPTURE_PORT];
} else if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
fmt = &inst->fmts[OUTPUT_PORT];
height = inst->prop.height[OUTPUT_PORT];
width = inst->prop.width[OUTPUT_PORT];
msm_venc_update_plane_count(inst, OUTPUT_PORT);
num_planes = inst->fmts[OUTPUT_PORT].num_planes;
num_planes = inst->prop.num_planes[OUTPUT_PORT];
} else {
dprintk(VIDC_ERR, "Invalid type: %x\n", f->type);
return -ENOTSUPP;
@ -4027,10 +4003,10 @@ int msm_venc_prepare_buf(struct msm_vidc_inst *inst,
case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
break;
case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
if (b->length != inst->fmts[CAPTURE_PORT].num_planes) {
if (b->length != inst->prop.num_planes[CAPTURE_PORT]) {
dprintk(VIDC_ERR,
"Planes mismatch: needed: %d, allocated: %d\n",
inst->fmts[CAPTURE_PORT].num_planes,
inst->prop.num_planes[CAPTURE_PORT],
b->length);
rc = -EINVAL;
break;
@ -4098,10 +4074,10 @@ int msm_venc_release_buf(struct msm_vidc_inst *inst,
break;
case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: {
if (b->length !=
inst->fmts[CAPTURE_PORT].num_planes) {
inst->prop.num_planes[CAPTURE_PORT]) {
dprintk(VIDC_ERR,
"Planes mismatch: needed: %d, to release: %d\n",
inst->fmts[CAPTURE_PORT].num_planes,
inst->prop.num_planes[CAPTURE_PORT],
b->length);
rc = -EINVAL;
break;

View file

@ -686,7 +686,7 @@ static bool valid_v4l2_buffer(struct v4l2_buffer *b,
MAX_PORT_NUM;
return port != MAX_PORT_NUM &&
inst->fmts[port].num_planes == b->length;
inst->prop.num_planes[port] == b->length;
}
int msm_vidc_prepare_buf(void *instance, struct v4l2_buffer *b)
@ -1317,9 +1317,6 @@ static void cleanup_instance(struct msm_vidc_inst *inst)
"Failed to release output buffers\n");
}
if (inst->extradata_handle)
msm_comm_smem_free(inst, inst->extradata_handle);
debugfs_remove_recursive(inst->debugfs_root);
mutex_lock(&inst->pending_getpropq.lock);

View file

@ -2079,7 +2079,7 @@ static void handle_fbd(enum hal_command_response cmd, void *data)
ns_to_timeval(time_usec * NSEC_PER_USEC);
vbuf->flags = 0;
extra_idx =
EXTRADATA_IDX(inst->fmts[CAPTURE_PORT].num_planes);
EXTRADATA_IDX(inst->prop.num_planes[CAPTURE_PORT]);
if (extra_idx && extra_idx < VIDEO_MAX_PLANES) {
vb->planes[extra_idx].m.userptr =
(unsigned long)fill_buf_done->extra_data_buffer;
@ -3639,7 +3639,7 @@ static void populate_frame_data(struct vidc_frame_data *data,
data->buffer_type = msm_comm_get_hal_output_buffer(inst);
}
extra_idx = EXTRADATA_IDX(inst->fmts[port].num_planes);
extra_idx = EXTRADATA_IDX(inst->prop.num_planes[port]);
if (extra_idx && extra_idx < VIDEO_MAX_PLANES &&
vb->planes[extra_idx].m.userptr) {
data->extradata_addr = vb->planes[extra_idx].m.userptr;

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@ -290,7 +290,7 @@ static ssize_t inst_info_read(struct file *file, char __user *buf,
write_str(&dbg_buf, "capability: %s\n", i == OUTPUT_PORT ?
"Output" : "Capture");
write_str(&dbg_buf, "name : %s\n", inst->fmts[i].name);
write_str(&dbg_buf, "planes : %d\n", inst->fmts[i].num_planes);
write_str(&dbg_buf, "planes : %d\n", inst->prop.num_planes[i]);
write_str(
&dbg_buf, "type: %s\n", inst->fmts[i].type == OUTPUT_PORT ?
"Output" : "Capture");
@ -311,7 +311,7 @@ static ssize_t inst_info_read(struct file *file, char __user *buf,
write_str(&dbg_buf, "count: %u\n",
inst->bufq[i].vb2_bufq.num_buffers);
for (j = 0; j < inst->fmts[i].num_planes; j++)
for (j = 0; j < inst->prop.num_planes[i]; j++)
write_str(&dbg_buf, "size for plane %d: %u\n", j,
inst->bufq[i].vb2_bufq.plane_sizes[j]);

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@ -143,7 +143,6 @@ struct msm_vidc_format {
char name[MAX_NAME_LENGTH];
u8 description[32];
u32 fourcc;
int num_planes;
int type;
u32 (*get_frame_size)(int plane, u32 height, u32 width);
};
@ -165,6 +164,8 @@ struct msm_video_device {
struct session_prop {
u32 width[MAX_PORT_NUM];
u32 height[MAX_PORT_NUM];
u32 num_planes[MAX_PORT_NUM];
u32 extradata[MAX_PORT_NUM];
u32 fps;
u32 bitrate;
};
@ -276,7 +277,6 @@ struct msm_vidc_inst {
struct completion completions[SESSION_MSG_END - SESSION_MSG_START + 1];
struct v4l2_ctrl **cluster;
struct v4l2_fh event_handler;
struct msm_smem *extradata_handle;
bool in_reconfig;
u32 reconfig_width;
u32 reconfig_height;