diff --git a/Makefile b/Makefile index a14220aa9b..e8a3137a3c 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only # auto-detect subdirs -ifneq ($(CONFIG_ARCH_QTI_VM), y) -ifeq ($(CONFIG_ARCH_WAIPIO), y) -include $(srctree)/techpack/video/config/waipio_video.conf -LINUXINCLUDE += -include $(srctree)/techpack/video/config/waipio_video.h -endif -endif LINUXINCLUDE += -I$(srctree)/techpack/video/include \ -I$(srctree)/techpack/video/include/uapi \ @@ -26,19 +20,23 @@ msm-vidc-objs := driver/vidc/src/msm_vidc_v4l2.o \ driver/vidc/src/msm_vidc.o \ driver/vidc/src/msm_vdec.o \ driver/vidc/src/msm_venc.o \ - driver/vidc/src/msm_vidc_vb2.o \ driver/vidc/src/msm_vidc_driver.o \ driver/vidc/src/msm_vidc_probe.o \ driver/vidc/src/msm_vidc_dt.o \ driver/vidc/src/msm_vidc_platform.o \ driver/vidc/src/msm_vidc_debug.o \ driver/vidc/src/msm_vidc_memory.o \ - driver/vidc/src/venus_hfi.o + driver/vidc/src/venus_hfi.o \ + driver/vidc/src/hfi_packet.o ifneq ($(CONFIG_ARCH_QTI_VM), y) -ifeq ($(CONFIG_ARCH_WAIPIO), y) +ifeq ($(CONFIG_ARCH_LAHAINA), y) + +include $(srctree)/techpack/video/config/waipio_video.conf +LINUXINCLUDE += -include $(srctree)/techpack/video/config/waipio_video.h + msm-vidc-objs += driver/platform/waipio/src/msm_vidc_waipio.o \ - driver/hfi/iris2/src/msm_vidc_iris2.o + driver/variant/iris2/src/msm_vidc_iris2.o endif endif diff --git a/driver/vidc/inc/hfi_packet.h b/driver/vidc/inc/hfi_packet.h index fcd7a22580..17fadf31a0 100644 --- a/driver/vidc/inc/hfi_packet.h +++ b/driver/vidc/inc/hfi_packet.h @@ -49,5 +49,8 @@ int hfi_packet_sys_debug_config(struct msm_vidc_core *core, void *packet, u32 packet_size, u32 mode); int hfi_packet_sys_pc_prep(struct msm_vidc_core *core, void *packet, u32 packet_size); - +int hfi_packet_session_open(struct msm_vidc_inst *inst, + void *packet, u32 pkt_size); +int hfi_packet_session_close(struct msm_vidc_inst *inst, + void *packet, u32 pkt_size); #endif // _HFI_PACKET_H_ diff --git a/driver/vidc/inc/msm_vdec.h b/driver/vidc/inc/msm_vdec.h index d0da941a24..2498f31bad 100644 --- a/driver/vidc/inc/msm_vdec.h +++ b/driver/vidc/inc/msm_vdec.h @@ -9,6 +9,8 @@ #include "msm_vidc_core.h" #include "msm_vidc_inst.h" +int msm_vdec_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f); +int msm_vdec_g_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f); int msm_vdec_inst_init(struct msm_vidc_inst *inst); int msm_vdec_ctrl_init(struct msm_vidc_inst *inst); diff --git a/driver/vidc/inc/msm_vidc_driver.h b/driver/vidc/inc/msm_vidc_driver.h index 36e7b9f1c9..e9584d2c4e 100644 --- a/driver/vidc/inc/msm_vidc_driver.h +++ b/driver/vidc/inc/msm_vidc_driver.h @@ -36,6 +36,12 @@ void msm_vidc_batch_handler(struct work_struct *work); int msm_vidc_setup_event_queue(struct msm_vidc_inst *inst); int msm_vidc_queue_init(struct msm_vidc_inst *inst); u32 msm_vidc_convert_color_fmt(u32 v4l2_fmt); +int msm_vidc_get_control(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl); +int msm_vidc_get_port_from_type(u32 type); +int msm_vidc_start_input(struct msm_vidc_inst *inst); +int msm_vidc_start_output(struct msm_vidc_inst *inst); +int msm_vidc_stop_input(struct msm_vidc_inst *inst); +int msm_vidc_stop_output(struct msm_vidc_inst *inst); #endif // _MSM_VIDC_DRIVER_H_ diff --git a/driver/vidc/inc/msm_vidc_inst.h b/driver/vidc/inc/msm_vidc_inst.h index 84b457449b..8544e5e098 100644 --- a/driver/vidc/inc/msm_vidc_inst.h +++ b/driver/vidc/inc/msm_vidc_inst.h @@ -82,6 +82,8 @@ struct msm_vidc_inst { struct kref kref; u32 session_id; u32 sid; + void *packet; + u32 packet_size; struct v4l2_format fmts[MAX_PORT]; struct v4l2_ctrl_handler ctrl_handler; struct v4l2_fh event_handler; diff --git a/driver/vidc/src/hfi_packet.c b/driver/vidc/src/hfi_packet.c index 7428966a3f..fb77fefe84 100644 --- a/driver/vidc/src/hfi_packet.c +++ b/driver/vidc/src/hfi_packet.c @@ -8,13 +8,43 @@ #include "msm_vidc_inst.h" #include "msm_vidc_debug.h" -int hfi_packet_sys_init(struct msm_vidc_core *core, void *pkt, u32 pkt_size) +int hfi_packet_sys_init(struct msm_vidc_core *core, + void *packet, u32 pkt_size) { d_vpr_h("%s()\n", __func__); return 0; } -int hfi_packet_sys_pc_prep(struct msm_vidc_core *core, void *pkt, u32 pkt_size) +int hfi_packet_sys_pc_prep(struct msm_vidc_core *core, + void *packet, u32 pkt_size) +{ + d_vpr_h("%s()\n", __func__); + return 0; +} + +int hfi_packet_sys_debug_config(struct msm_vidc_core *core, + void *packet, u32 pkt_size, u32 config) +{ + d_vpr_h("%s()\n", __func__); + return 0; +} + +int hfi_packet_image_version(struct msm_vidc_core *core, + void *packet, u32 pkt_size) +{ + d_vpr_h("%s()\n", __func__); + return 0; +} + +int hfi_packet_session_open(struct msm_vidc_inst *inst, + void *packet, u32 pkt_size) +{ + d_vpr_h("%s()\n", __func__); + return 0; +} + +int hfi_packet_session_close(struct msm_vidc_inst *inst, + void *packet, u32 pkt_size) { d_vpr_h("%s()\n", __func__); return 0; diff --git a/driver/vidc/src/msm_vdec.c b/driver/vidc/src/msm_vdec.c index 1fd149f5a7..1db9736722 100644 --- a/driver/vidc/src/msm_vdec.c +++ b/driver/vidc/src/msm_vdec.c @@ -14,6 +14,202 @@ #include "msm_vidc_platform.h" #include "msm_vidc_debug.h" +static int msm_vdec_codec_change(struct msm_vidc_inst *inst, u32 codec) +{ + int rc = 0; + struct msm_vidc_core *core; + + d_vpr_h("%s()\n", __func__); + if (!inst || !inst->core) { + d_vpr_e("%s: invalid params\n", __func__); + return -EINVAL; + } + core = inst->core; + + return rc; +} + +int msm_vdec_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f) +{ + int rc = 0; + struct msm_vidc_core *core; + struct v4l2_format *fmt; + + d_vpr_h("%s()\n", __func__); + if (!inst || !inst->core) { + d_vpr_e("%s: invalid params\n", __func__); + return -EINVAL; + } + core = inst->core; + + if (inst->state == MSM_VIDC_START) { + d_vpr_e("%s: invalid state %d\n", __func__, inst->state); + return -EINVAL; + } + + if (f->type == INPUT_PLANE) { + if (inst->state == MSM_VIDC_START_INPUT) { + d_vpr_e("%s: invalid state %d\n", __func__, inst->state); + return -EINVAL; + } + if (inst->fmts[INPUT_PORT].fmt.pix.pixelformat != + f->fmt.pix.pixelformat) { + s_vpr_e(inst->sid, + "%s: codec changed from %#x to %#x\n", __func__, + inst->fmts[INPUT_PORT].fmt.pix.pixelformat, + f->fmt.pix.pixelformat); + rc = msm_vdec_codec_change(inst, f->fmt.pix.pixelformat); + if (rc) + goto err_invalid_fmt; + } + fmt = &inst->fmts[INPUT_PORT]; + fmt->type = INPUT_PLANE; + fmt->fmt.pix.width = f->fmt.pix.width; + fmt->fmt.pix.height = f->fmt.pix.height; + fmt->fmt.pix.pixelformat = f->fmt.pix.pixelformat; + fmt->fmt.pix.bytesperline = 0; + fmt->fmt.pix.sizeimage = call_session_op(core, buffer_size, + inst, MSM_VIDC_INPUT); + inst->buffers.input.min_count = + call_session_op(core, min_count, inst, MSM_VIDC_INPUT); + inst->buffers.input.extra_count = + call_session_op(core, extra_count, inst, MSM_VIDC_INPUT); + if (inst->buffers.input.actual_count < + inst->buffers.input.min_count + + inst->buffers.input.extra_count) { + inst->buffers.input.actual_count = + inst->buffers.input.min_count + + inst->buffers.input.extra_count; + } + inst->buffers.input.size = fmt->fmt.pix.sizeimage; + + //rc = msm_vidc_check_session_supported(inst); + if (rc) + goto err_invalid_fmt; + //update_log_ctxt(inst->sid, inst->session_type, + // mplane->pixelformat); + s_vpr_h(inst->sid, + "%s: input: codec %#x width %d height %d size %d min_count %d extra_count %d\n", + __func__, fmt->fmt.pix.pixelformat, fmt->fmt.pix.width, + fmt->fmt.pix.height, fmt->fmt.pix.sizeimage, + inst->buffers.input.min_count, + inst->buffers.input.extra_count); + } else if (f->type == INPUT_META_PLANE) { + if (inst->state == MSM_VIDC_START_INPUT) { + d_vpr_e("%s: invalid state %d\n", __func__, inst->state); + return -EINVAL; + } + fmt = &inst->fmts[INPUT_META_PORT]; + fmt->type = INPUT_META_PLANE; + fmt->fmt.meta.dataformat = V4L2_PIX_FMT_VIDC_META; + fmt->fmt.meta.buffersize = call_session_op(core, buffer_size, + inst, MSM_VIDC_INPUT_META); + inst->buffers.input_meta.min_count = + inst->buffers.input.min_count; + inst->buffers.input_meta.extra_count = + inst->buffers.input.extra_count; + inst->buffers.input_meta.actual_count = + inst->buffers.input.actual_count; + inst->buffers.input_meta.size = fmt->fmt.meta.buffersize; + s_vpr_h(inst->sid, + "%s: input meta: size %d min_count %d extra_count %d\n", + __func__, fmt->fmt.meta.buffersize, + inst->buffers.input_meta.min_count, + inst->buffers.input_meta.extra_count); + } else if (f->type == OUTPUT_PLANE) { + if (inst->state == MSM_VIDC_START_OUTPUT) { + d_vpr_e("%s: invalid state %d\n", __func__, inst->state); + return -EINVAL; + } + fmt = &inst->fmts[OUTPUT_PORT]; + fmt->type = OUTPUT_PLANE; + fmt->fmt.pix.pixelformat = f->fmt.pix.pixelformat; + fmt->fmt.pix.width = VENUS_Y_STRIDE( + msm_vidc_convert_color_fmt(fmt->fmt.pix.pixelformat), + f->fmt.pix.width); + fmt->fmt.pix.height = VENUS_Y_SCANLINES( + msm_vidc_convert_color_fmt(fmt->fmt.pix.pixelformat), + f->fmt.pix.height); + fmt->fmt.pix.bytesperline = fmt->fmt.pix.width; + fmt->fmt.pix.sizeimage = call_session_op(core, buffer_size, + inst, MSM_VIDC_OUTPUT); + inst->buffers.output.min_count = + call_session_op(core, min_count, inst, MSM_VIDC_OUTPUT); + inst->buffers.output.extra_count = + call_session_op(core, extra_count, inst, MSM_VIDC_OUTPUT); + if (inst->buffers.output.actual_count < + inst->buffers.output.min_count + + inst->buffers.output.extra_count) { + inst->buffers.output.actual_count = + inst->buffers.output.min_count + + inst->buffers.output.extra_count; + } + inst->buffers.output.size = fmt->fmt.pix.sizeimage; + + //rc = msm_vidc_check_session_supported(inst); + if (rc) + goto err_invalid_fmt; + s_vpr_h(inst->sid, + "%s: output: format %#x width %d height %d size %d min_count %d extra_count %d\n", + __func__, fmt->fmt.pix.pixelformat, fmt->fmt.pix.width, + fmt->fmt.pix.height, fmt->fmt.pix.sizeimage, + inst->buffers.output.min_count, + inst->buffers.output.extra_count); + } else if (f->type == OUTPUT_META_PLANE) { + if (inst->state == MSM_VIDC_START_OUTPUT) { + d_vpr_e("%s: invalid state %d\n", __func__, inst->state); + return -EINVAL; + } + fmt = &inst->fmts[OUTPUT_META_PORT]; + fmt->type = OUTPUT_META_PLANE; + fmt->fmt.meta.dataformat = V4L2_PIX_FMT_VIDC_META; + fmt->fmt.meta.buffersize = call_session_op(core, buffer_size, + inst, MSM_VIDC_OUTPUT_META); + inst->buffers.output_meta.min_count = + inst->buffers.output.min_count; + inst->buffers.output_meta.extra_count = + inst->buffers.output.extra_count; + inst->buffers.output_meta.actual_count = + inst->buffers.output.actual_count; + inst->buffers.output_meta.size = fmt->fmt.meta.buffersize; + s_vpr_h(inst->sid, + "%s: input meta: size %d min_count %d extra_count %d\n", + __func__, fmt->fmt.meta.buffersize, + inst->buffers.output_meta.min_count, + inst->buffers.output_meta.extra_count); + } + +err_invalid_fmt: + return rc; +} + +int msm_vdec_g_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f) +{ + int rc = 0; + u32 index; + + d_vpr_h("%s()\n", __func__); + if (!inst) { + d_vpr_e("%s: invalid params\n", __func__); + return -EINVAL; + } + + if (f->type == OUTPUT_PLANE) { + index = OUTPUT_PORT; + } else if (f->type == INPUT_PLANE) { + index = OUTPUT_PORT; + } else if (f->type == OUTPUT_META_PLANE) { + index = OUTPUT_PORT; + } else if (f->type == OUTPUT_META_PLANE) { + index = OUTPUT_PORT; + } else { + d_vpr_e("%s: invalid type %d\n", __func__, f->type); + return -EINVAL; + } + memcpy(f, &inst->fmts[index], sizeof(struct v4l2_format)); + + return rc; +} int msm_vdec_inst_init(struct msm_vidc_inst *inst) { @@ -84,7 +280,7 @@ int msm_vdec_inst_init(struct msm_vidc_inst *inst) inst->buffers.output_meta.min_count = inst->buffers.output.min_count; inst->buffers.output_meta.extra_count = inst->buffers.output.extra_count; inst->buffers.output_meta.actual_count = inst->buffers.output.actual_count; - inst->buffers.output_meta.size = f->fmt.meta.buffersize; + inst->buffers.output_meta.size = f->fmt.meta.buffersize; inst->prop.frame_rate = DEFAULT_FPS << 16; inst->prop.operating_rate = DEFAULT_FPS << 16; diff --git a/driver/vidc/src/msm_vidc.c b/driver/vidc/src/msm_vidc.c index 9289019791..99e080b70c 100644 --- a/driver/vidc/src/msm_vidc.c +++ b/driver/vidc/src/msm_vidc.c @@ -147,17 +147,8 @@ int msm_vidc_query_ctrl(void *instance, struct v4l2_queryctrl *q_ctrl) q_ctrl->minimum = ctrl->minimum; q_ctrl->maximum = ctrl->maximum; q_ctrl->default_value = ctrl->default_value; - /* remove tier info for HEVC level */ - if (q_ctrl->id == V4L2_CID_MPEG_VIDEO_HEVC_LEVEL) { - q_ctrl->minimum &= ~(0xF << 28); - q_ctrl->maximum &= ~(0xF << 28); - } - if (ctrl->type == V4L2_CTRL_TYPE_MENU) { - q_ctrl->flags = ~(ctrl->menu_skip_mask); - } else { - q_ctrl->flags = 0; - q_ctrl->step = ctrl->step; - } + q_ctrl->flags = 0; + q_ctrl->step = ctrl->step; s_vpr_h(inst->sid, "query ctrl: %s: min %d, max %d, default %d step %d flags %#x\n", ctrl->name, q_ctrl->minimum, q_ctrl->maximum, @@ -213,7 +204,7 @@ int msm_vidc_s_fmt(void *instance, struct v4l2_format *f) return -EINVAL; if (inst->domain == MSM_VIDC_DECODER) - rc = 0;//msm_vdec_s_fmt(instance, f); + rc = msm_vdec_s_fmt(inst, f); if (inst->domain == MSM_VIDC_ENCODER) rc = 0;//msm_venc_s_fmt(instance, f); @@ -230,7 +221,7 @@ int msm_vidc_g_fmt(void *instance, struct v4l2_format *f) return -EINVAL; if (inst->domain == MSM_VIDC_DECODER) - rc = 0;//msm_vdec_g_fmt(instance, f); + rc = msm_vdec_g_fmt(inst, f); if (inst->domain == MSM_VIDC_ENCODER) rc = 0;//msm_venc_g_fmt(instance, f); @@ -260,7 +251,7 @@ int msm_vidc_g_ctrl(void *instance, struct v4l2_control *control) ctrl = v4l2_ctrl_find(&inst->ctrl_handler, control->id); if (ctrl) { - rc = 0;//try_get_ctrl_for_instance(inst, ctrl); + rc = msm_vidc_get_control(inst, ctrl); if (!rc) control->value = ctrl->val; } @@ -271,7 +262,25 @@ EXPORT_SYMBOL(msm_vidc_g_ctrl); int msm_vidc_reqbufs(void *instance, struct v4l2_requestbuffers *b) { - return 0; + int rc = 0; + struct msm_vidc_inst *inst = instance; + int port; + + if (!inst || !b) + return -EINVAL; + + port = msm_vidc_get_port_from_type(b->type); + if (port < 0) { + d_vpr_e("%s: invalid queue type %d\n", __func__, b->type); + return -EINVAL; + } + mutex_lock(&inst->lock); + rc = vb2_reqbufs(&inst->vb2q[port], b); + mutex_unlock(&inst->lock); + if (rc) + s_vpr_e(inst->sid, "%s: vb2_reqbufs failed, %d\n", rc); + + return rc; } EXPORT_SYMBOL(msm_vidc_reqbufs); @@ -290,13 +299,49 @@ EXPORT_SYMBOL(msm_vidc_dqbuf); int msm_vidc_streamon(void *instance, enum v4l2_buf_type i) { - return 0; + int rc = 0; + struct msm_vidc_inst *inst = instance; + int port; + + if (!inst) + return -EINVAL; + + port = msm_vidc_get_port_from_type(i); + if (port < 0) { + d_vpr_e("%s: invalid buf type %d\n", __func__, i); + return -EINVAL; + } + mutex_lock(&inst->lock); + rc = vb2_streamon(&inst->vb2q[port], i); + mutex_unlock(&inst->lock); + if (rc) + s_vpr_e(inst->sid, "%s: vb2_streamon failed, %d\n", rc); + + return rc; } EXPORT_SYMBOL(msm_vidc_streamon); int msm_vidc_streamoff(void *instance, enum v4l2_buf_type i) { - return 0; + int rc = 0; + struct msm_vidc_inst *inst = instance; + int port; + + if (!inst) + return -EINVAL; + + port = msm_vidc_get_port_from_type(i); + if (port < 0) { + d_vpr_e("%s: invalid buf type %d\n", __func__, i); + return -EINVAL; + } + mutex_lock(&inst->lock); + rc = vb2_streamoff(&inst->vb2q[port], i); + mutex_unlock(&inst->lock); + if (rc) + s_vpr_e(inst->sid, "%s: vb2_streamoff failed, %d\n", rc); + + return rc; } EXPORT_SYMBOL(msm_vidc_streamoff); diff --git a/driver/vidc/src/msm_vidc_driver.c b/driver/vidc/src/msm_vidc_driver.c index bc56a27f32..c9a7c24995 100644 --- a/driver/vidc/src/msm_vidc_driver.c +++ b/driver/vidc/src/msm_vidc_driver.c @@ -13,6 +13,52 @@ #include "msm_vidc_debug.h" #include "venus_hfi.h" +int msm_vidc_get_port_from_type(u32 type) +{ + int port; + + if (type == INPUT_PLANE) { + port = INPUT_PORT; + } else if (type == INPUT_META_PLANE) { + port = INPUT_META_PORT; + } else if (type == OUTPUT_PLANE) { + port = OUTPUT_PORT; + } else if (type == OUTPUT_META_PLANE) { + port = OUTPUT_META_PORT; + } else { + d_vpr_e("invalid type %d\n", type); + port = -EINVAL; + } + + return port; +} +int msm_vidc_get_control(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl) +{ + int rc = 0; + + if (!inst || !ctrl) { + d_vpr_e("%s: invalid params\n", __func__); + return -EINVAL; + } + + switch (ctrl->id) { + case V4L2_CID_MIN_BUFFERS_FOR_CAPTURE: + ctrl->val = inst->buffers.output.min_count + + inst->buffers.output.extra_count; + s_vpr_h(inst->sid, "g_min: output buffers %d\n", ctrl->val); + break; + case V4L2_CID_MIN_BUFFERS_FOR_OUTPUT: + ctrl->val = inst->buffers.input.min_count + + inst->buffers.input.extra_count; + s_vpr_h(inst->sid, "g_min: input buffers %d\n", ctrl->val); + break; + default: + break; + } + + return rc; +} + u32 msm_vidc_convert_color_fmt(u32 v4l2_fmt) { switch (v4l2_fmt) { @@ -38,10 +84,68 @@ u32 msm_vidc_convert_color_fmt(u32 v4l2_fmt) } } +int msm_vidc_stop_input(struct msm_vidc_inst *inst) +{ + int rc = 0; + + d_vpr_h("%s()\n", __func__); + if (!inst) { + d_vpr_e("%s: invalid params\n", __func__); + return -EINVAL; + } + + return rc; +} + +int msm_vidc_stop_output(struct msm_vidc_inst *inst) +{ + int rc = 0; + + d_vpr_h("%s()\n", __func__); + if (!inst) { + d_vpr_e("%s: invalid params\n", __func__); + return -EINVAL; + } + + return rc; +} + +int msm_vidc_start_input(struct msm_vidc_inst *inst) +{ + int rc = 0; + + d_vpr_h("%s()\n", __func__); + if (!inst) { + d_vpr_e("%s: invalid params\n", __func__); + return -EINVAL; + } + + return rc; +} + +int msm_vidc_start_output(struct msm_vidc_inst *inst) +{ + int rc = 0; + + d_vpr_h("%s()\n", __func__); + if (!inst) { + d_vpr_e("%s: invalid params\n", __func__); + return -EINVAL; + } + + return rc; +} + int msm_vidc_setup_event_queue(struct msm_vidc_inst *inst) { int rc = 0; + d_vpr_h("%s()\n", __func__); + if (!inst) { + d_vpr_e("%s: invalid params\n", __func__); + return -EINVAL; + } + return rc; } @@ -49,6 +153,12 @@ int msm_vidc_queue_init(struct msm_vidc_inst *inst) { int rc = 0; + d_vpr_h("%s()\n", __func__); + if (!inst) { + d_vpr_e("%s: invalid params\n", __func__); + return -EINVAL; + } + return rc; } @@ -72,7 +182,7 @@ int msm_vidc_add_session(struct msm_vidc_inst *inst) if (count < MAX_SUPPORTED_INSTANCES) { list_add_tail(&inst->list, &core->instances); } else { - d_vpr_e("%s: total sessions %d reached max limit %d\n", + d_vpr_e("%s: total sessions %d exceeded max limit %d\n", __func__, count, MAX_SUPPORTED_INSTANCES); rc = -EINVAL; } diff --git a/driver/vidc/src/msm_vidc_vb2.c b/driver/vidc/src/msm_vidc_vb2.c index deb535abc1..0d82cd5343 100644 --- a/driver/vidc/src/msm_vidc_vb2.c +++ b/driver/vidc/src/msm_vidc_vb2.c @@ -7,6 +7,7 @@ #include "msm_vidc_core.h" #include "msm_vidc_inst.h" #include "msm_vidc_internal.h" +#include "msm_vidc_driver.h" #include "msm_vidc_debug.h" void *msm_vb2_get_userptr(struct device *dev, unsigned long vaddr, @@ -23,12 +24,90 @@ int msm_vidc_queue_setup(struct vb2_queue *q, unsigned int *num_buffers, unsigned int *num_planes, unsigned int sizes[], struct device *alloc_devs[]) { - return 0; + int rc = 0; + struct msm_vidc_inst *inst; + int port; + + if (!q || !num_buffers || !num_planes + || !sizes || !q->drv_priv) { + d_vpr_e("%s: invalid params, q = %pK, %pK, %pK\n", + __func__, q, num_buffers, num_planes); + return -EINVAL; + } + inst = q->drv_priv; + if (!inst || !inst->core) { + d_vpr_e("%s: invalid params %pK\n", __func__, inst); + return -EINVAL; + } + if (inst->state == MSM_VIDC_START) { + d_vpr_e("%s: invalid state %d\n", __func__, inst->state); + return -EINVAL; + } + + port = msm_vidc_get_port_from_type(q->type); + if (port < 0) { + d_vpr_e("%s: invalid queue type %d\n", __func__, q->type); + return -EINVAL; + } + if (port == INPUT_PORT || port == INPUT_META_PORT) { + if (inst->state == MSM_VIDC_START_INPUT) { + d_vpr_e("%s: input invalid state %d\n", + __func__, inst->state); + return -EINVAL; + } + } else if (port == OUTPUT_PORT || port == OUTPUT_META_PORT) { + if (inst->state == MSM_VIDC_START_OUTPUT) { + d_vpr_e("%s: output invalid state %d\n", + __func__, inst->state); + return -EINVAL; + } + } + + *num_planes = 1; + if (*num_buffers < inst->buffers.input.min_count + + inst->buffers.input.extra_count) + *num_buffers = inst->buffers.input.min_count + + inst->buffers.input.extra_count; + sizes[0] = inst->fmts[port].fmt.pix.sizeimage; + inst->buffers.input.actual_count = *num_buffers; + + s_vpr_h(inst->sid, + "queue_setup: type %d num_buffers %d sizes[0] %d\n", + q->type, *num_buffers, sizes[0]); + return rc; } int msm_vidc_start_streaming(struct vb2_queue *q, unsigned int count) { - return 0; + int rc = 0; + struct msm_vidc_inst *inst; + + if (!q || !q->drv_priv) { + d_vpr_e("%s: invalid input, q = %pK\n", q); + return -EINVAL; + } + inst = q->drv_priv; + if (!inst || !inst->core) { + d_vpr_e("%s: invalid params\n", __func__); + return -EINVAL; + } + if (q->type == INPUT_META_PLANE || q->type == OUTPUT_META_PLANE) { + s_vpr_h(inst->sid, "%s: nothing to start on meta port %d\n", + __func__, q->type); + return 0; + } + s_vpr_h(inst->sid, "Streamon: %d\n", q->type); + + if (q->type == INPUT_PLANE) { + rc = msm_vidc_start_input(inst); + } else if (q->type == INPUT_PLANE) { + rc = msm_vidc_start_output(inst); + } else { + s_vpr_e(inst->sid, "%s: invalid type %d\n", __func__, q->type); + rc = -EINVAL; + } + + return rc; } void msm_vidc_stop_streaming(struct vb2_queue *q) diff --git a/driver/vidc/src/venus_hfi.c b/driver/vidc/src/venus_hfi.c index a809025fe1..c76e7c48be 100644 --- a/driver/vidc/src/venus_hfi.c +++ b/driver/vidc/src/venus_hfi.c @@ -2322,7 +2322,7 @@ int venus_hfi_suspend(struct msm_vidc_core *core) int rc = 0; if (!core) { - d_vpr_e("%s: invalid device\n", __func__); + d_vpr_e("%s: invalid params\n", __func__); return -EINVAL; } @@ -2346,6 +2346,21 @@ int venus_hfi_session_open(struct msm_vidc_core *core, struct msm_vidc_inst *ins d_vpr_h("%s(): inst %p, core %p\n", __func__, inst, core); + if (!core || !inst) { + d_vpr_e("%s: invalid params\n", __func__); + return -EINVAL; + } + + inst->packet_size = 4096; + inst->packet = kzalloc(inst->packet_size, GFP_KERNEL); + if (!inst->packet) { + d_vpr_e("%s(): inst packet allocation failed\n", __func__); + return -ENOMEM; + } + rc = hfi_packet_session_open(inst, inst->packet, inst->packet_size); + if (rc) + return rc; + return rc; }