1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903 |
- // SPDX-License-Identifier: GPL-2.0-only
- /*
- * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
- */
- #include <media/v4l2_vidc_extensions.h>
- #include "msm_media_info.h"
- #include "msm_venc.h"
- #include "msm_vidc_core.h"
- #include "msm_vidc_inst.h"
- #include "msm_vidc_driver.h"
- #include "msm_vidc_internal.h"
- #include "msm_vidc_platform.h"
- #include "msm_vidc_control.h"
- #include "msm_vidc_debug.h"
- #include "msm_vidc_power.h"
- #include "venus_hfi.h"
- #include "hfi_packet.h"
- static const u32 msm_venc_input_set_prop[] = {
- HFI_PROP_COLOR_FORMAT,
- HFI_PROP_RAW_RESOLUTION,
- HFI_PROP_LINEAR_STRIDE_SCANLINE,
- HFI_PROP_SIGNAL_COLOR_INFO,
- };
- static const u32 msm_venc_output_set_prop[] = {
- HFI_PROP_BITSTREAM_RESOLUTION,
- HFI_PROP_CROP_OFFSETS,
- HFI_PROP_CSC,
- };
- static const u32 msm_venc_input_subscribe_for_properties[] = {
- HFI_PROP_NO_OUTPUT,
- };
- static const u32 msm_venc_output_subscribe_for_properties[] = {
- HFI_PROP_PICTURE_TYPE,
- HFI_PROP_BUFFER_MARK,
- HFI_PROP_WORST_COMPRESSION_RATIO,
- };
- static const u32 msm_venc_output_internal_buffer_type[] = {
- MSM_VIDC_BUF_BIN,
- MSM_VIDC_BUF_COMV,
- MSM_VIDC_BUF_NON_COMV,
- MSM_VIDC_BUF_LINE,
- MSM_VIDC_BUF_DPB,
- };
- static const u32 msm_venc_input_internal_buffer_type[] = {
- MSM_VIDC_BUF_VPSS,
- };
- struct msm_venc_prop_type_handle {
- u32 type;
- int (*handle)(struct msm_vidc_inst *inst, enum msm_vidc_port_type port);
- };
- static int msm_venc_codec_change(struct msm_vidc_inst *inst, u32 v4l2_codec)
- {
- int rc = 0;
- if (inst->codec && inst->fmts[OUTPUT_PORT].fmt.pix_mp.pixelformat == v4l2_codec)
- return 0;
- i_vpr_h(inst, "%s: codec changed from %s to %s\n",
- __func__, v4l2_pixelfmt_name(inst->fmts[OUTPUT_PORT].fmt.pix_mp.pixelformat),
- v4l2_pixelfmt_name(v4l2_codec));
- inst->codec = v4l2_codec_to_driver(v4l2_codec, __func__);
- if (!inst->codec) {
- i_vpr_e(inst, "%s: invalid codec %#x\n", __func__, v4l2_codec);
- rc = -EINVAL;
- goto exit;
- }
- inst->fmts[OUTPUT_PORT].fmt.pix_mp.pixelformat = v4l2_codec;
- rc = msm_vidc_update_debug_str(inst);
- if (rc)
- goto exit;
- rc = msm_vidc_get_inst_capability(inst);
- if (rc)
- goto exit;
- rc = msm_vidc_ctrl_deinit(inst);
- if (rc)
- goto exit;
- rc = msm_vidc_ctrl_init(inst);
- if (rc)
- goto exit;
- rc = msm_vidc_update_buffer_count(inst, INPUT_PORT);
- if (rc)
- goto exit;
- rc = msm_vidc_update_buffer_count(inst, OUTPUT_PORT);
- if (rc)
- goto exit;
- exit:
- return rc;
- }
- /* todo: add logs for each property once finalised */
- static int msm_venc_set_colorformat(struct msm_vidc_inst *inst,
- enum msm_vidc_port_type port)
- {
- int rc = 0;
- u32 pixelformat;
- enum msm_vidc_colorformat_type colorformat;
- u32 hfi_colorformat;
- if (port != INPUT_PORT) {
- i_vpr_e(inst, "%s: invalid port %d\n", __func__, port);
- return -EINVAL;
- }
- pixelformat = inst->fmts[INPUT_PORT].fmt.pix_mp.pixelformat;
- colorformat = v4l2_colorformat_to_driver(pixelformat, __func__);
- if (!(colorformat & inst->capabilities->cap[PIX_FMTS].step_or_mask)) {
- i_vpr_e(inst, "%s: invalid pixelformat %s\n",
- __func__, v4l2_pixelfmt_name(pixelformat));
- return -EINVAL;
- }
- hfi_colorformat = get_hfi_colorformat(inst, colorformat);
- i_vpr_h(inst, "%s: hfi colorformat: %#x", __func__,
- hfi_colorformat);
- rc = venus_hfi_session_property(inst,
- HFI_PROP_COLOR_FORMAT,
- HFI_HOST_FLAGS_NONE,
- get_hfi_port(inst, port),
- HFI_PAYLOAD_U32_ENUM,
- &hfi_colorformat,
- sizeof(u32));
- if (rc)
- return rc;
- return 0;
- }
- static int msm_venc_set_stride_scanline(struct msm_vidc_inst *inst,
- enum msm_vidc_port_type port)
- {
- int rc = 0;
- u32 color_format, stride_y, scanline_y;
- u32 stride_uv = 0, scanline_uv = 0;
- u32 payload[2];
- if (port != INPUT_PORT) {
- i_vpr_e(inst, "%s: invalid port %d\n", __func__, port);
- return -EINVAL;
- }
- color_format = inst->capabilities->cap[PIX_FMTS].value;
- if (!is_linear_colorformat(color_format)) {
- i_vpr_h(inst,
- "%s: not a linear color fmt, property is not set\n",
- __func__);
- return 0;
- }
- if (is_image_session(inst)) {
- stride_y = ALIGN(inst->fmts[INPUT_PORT].fmt.pix_mp.width, HEIC_GRID_DIMENSION);
- scanline_y = ALIGN(inst->fmts[INPUT_PORT].fmt.pix_mp.height, HEIC_GRID_DIMENSION);
- } else if (is_rgba_colorformat(color_format)) {
- stride_y = video_rgb_stride_pix(color_format,
- inst->fmts[INPUT_PORT].fmt.pix_mp.width);
- scanline_y = video_rgb_scanlines(color_format,
- inst->fmts[INPUT_PORT].fmt.pix_mp.height);
- } else {
- stride_y = video_y_stride_pix(color_format,
- inst->fmts[INPUT_PORT].fmt.pix_mp.width);
- scanline_y = video_y_scanlines(color_format,
- inst->fmts[INPUT_PORT].fmt.pix_mp.height);
- }
- if (color_format == MSM_VIDC_FMT_NV12 ||
- color_format == MSM_VIDC_FMT_P010 ||
- color_format == MSM_VIDC_FMT_NV21) {
- stride_uv = stride_y;
- scanline_uv = scanline_y / 2;
- }
- payload[0] = stride_y << 16 | scanline_y;
- payload[1] = stride_uv << 16 | scanline_uv;
- i_vpr_h(inst, "%s: stride_y: %d scanline_y: %d "
- "stride_uv: %d, scanline_uv: %d", __func__,
- stride_y, scanline_y, stride_uv, scanline_uv);
- rc = venus_hfi_session_property(inst,
- HFI_PROP_LINEAR_STRIDE_SCANLINE,
- HFI_HOST_FLAGS_NONE,
- get_hfi_port(inst, port),
- HFI_PAYLOAD_64_PACKED,
- &payload,
- sizeof(u64));
- if (rc)
- return rc;
- return 0;
- }
- static int msm_venc_set_raw_resolution(struct msm_vidc_inst *inst,
- enum msm_vidc_port_type port)
- {
- int rc = 0;
- u32 resolution;
- if (port != INPUT_PORT) {
- i_vpr_e(inst, "%s: invalid port %d\n", __func__, port);
- return -EINVAL;
- }
- resolution = inst->crop.width << 16 | inst->crop.height;
- i_vpr_h(inst, "%s: width: %d height: %d\n", __func__,
- inst->crop.width, inst->crop.height);
- rc = venus_hfi_session_property(inst,
- HFI_PROP_RAW_RESOLUTION,
- HFI_HOST_FLAGS_NONE,
- get_hfi_port(inst, port),
- HFI_PAYLOAD_32_PACKED,
- &resolution,
- sizeof(u32));
- if (rc)
- return rc;
- return 0;
- }
- static int msm_venc_set_bitstream_resolution(struct msm_vidc_inst *inst,
- enum msm_vidc_port_type port)
- {
- int rc = 0;
- u32 resolution;
- if (port != OUTPUT_PORT) {
- i_vpr_e(inst, "%s: invalid port %d\n", __func__, port);
- return -EINVAL;
- }
- resolution = (inst->fmts[port].fmt.pix_mp.width << 16) |
- inst->fmts[port].fmt.pix_mp.height;
- i_vpr_h(inst, "%s: width: %d height: %d\n", __func__,
- inst->fmts[port].fmt.pix_mp.width,
- inst->fmts[port].fmt.pix_mp.height);
- rc = venus_hfi_session_property(inst,
- HFI_PROP_BITSTREAM_RESOLUTION,
- HFI_HOST_FLAGS_NONE,
- get_hfi_port(inst, port),
- HFI_PAYLOAD_32_PACKED,
- &resolution,
- sizeof(u32));
- if (rc)
- return rc;
- return 0;
- }
- static int msm_venc_set_crop_offsets(struct msm_vidc_inst *inst,
- enum msm_vidc_port_type port)
- {
- int rc = 0;
- u32 left_offset, top_offset, right_offset, bottom_offset;
- u32 crop[2] = {0};
- u32 width, height;
- if (port != OUTPUT_PORT) {
- i_vpr_e(inst, "%s: invalid port %d\n", __func__, port);
- return -EINVAL;
- }
- left_offset = inst->compose.left;
- top_offset = inst->compose.top;
- width = inst->compose.width;
- height = inst->compose.height;
- if (is_rotation_90_or_270(inst)) {
- width = inst->compose.height;
- height = inst->compose.width;
- }
- right_offset = (inst->fmts[port].fmt.pix_mp.width - width);
- bottom_offset = (inst->fmts[port].fmt.pix_mp.height - height);
- if (is_image_session(inst))
- right_offset = bottom_offset = 0;
- crop[0] = left_offset << 16 | top_offset;
- crop[1] = right_offset << 16 | bottom_offset;
- i_vpr_h(inst, "%s: left_offset: %d top_offset: %d "
- "right_offset: %d bottom_offset: %d", __func__,
- left_offset, top_offset, right_offset, bottom_offset);
- rc = venus_hfi_session_property(inst,
- HFI_PROP_CROP_OFFSETS,
- HFI_HOST_FLAGS_NONE,
- get_hfi_port(inst, port),
- HFI_PAYLOAD_64_PACKED,
- &crop,
- sizeof(u64));
- if (rc)
- return rc;
- return 0;
- }
- static int msm_venc_set_colorspace(struct msm_vidc_inst* inst,
- enum msm_vidc_port_type port)
- {
- int rc = 0;
- u32 primaries = MSM_VIDC_PRIMARIES_RESERVED;
- u32 matrix_coeff = MSM_VIDC_MATRIX_COEFF_RESERVED;
- u32 transfer_char = MSM_VIDC_TRANSFER_RESERVED;
- u32 full_range = 0;
- u32 colour_description_present_flag = 0;
- u32 video_signal_type_present_flag = 0, payload = 0;
- /* Unspecified video format */
- u32 video_format = 5;
- struct v4l2_format *input_fmt;
- u32 pix_fmt;
- if (port != INPUT_PORT) {
- i_vpr_e(inst, "%s: invalid port %d\n", __func__, port);
- return -EINVAL;
- }
- input_fmt = &inst->fmts[INPUT_PORT];
- pix_fmt = v4l2_colorformat_to_driver(
- input_fmt->fmt.pix_mp.pixelformat, __func__);
- if (inst->fmts[port].fmt.pix_mp.colorspace != V4L2_COLORSPACE_DEFAULT ||
- inst->fmts[port].fmt.pix_mp.ycbcr_enc != V4L2_YCBCR_ENC_DEFAULT ||
- inst->fmts[port].fmt.pix_mp.xfer_func != V4L2_XFER_FUNC_DEFAULT) {
- colour_description_present_flag = 1;
- video_signal_type_present_flag = 1;
- primaries = v4l2_color_primaries_to_driver(inst,
- inst->fmts[port].fmt.pix_mp.colorspace, __func__);
- matrix_coeff = v4l2_matrix_coeff_to_driver(inst,
- inst->fmts[port].fmt.pix_mp.ycbcr_enc, __func__);
- transfer_char = v4l2_transfer_char_to_driver(inst,
- inst->fmts[port].fmt.pix_mp.xfer_func, __func__);
- } else if (is_rgba_colorformat(pix_fmt)) {
- colour_description_present_flag = 1;
- video_signal_type_present_flag = 1;
- primaries = MSM_VIDC_PRIMARIES_BT709;
- matrix_coeff = MSM_VIDC_MATRIX_COEFF_BT709;
- transfer_char = MSM_VIDC_TRANSFER_BT709;
- full_range = 0;
- }
- if (inst->fmts[port].fmt.pix_mp.quantization !=
- V4L2_QUANTIZATION_DEFAULT) {
- video_signal_type_present_flag = 1;
- full_range = inst->fmts[port].fmt.pix_mp.quantization ==
- V4L2_QUANTIZATION_FULL_RANGE ? 1 : 0;
- }
- payload = (matrix_coeff & 0xFF) |
- ((transfer_char << 8) & 0xFF00) |
- ((primaries << 16) & 0xFF0000) |
- ((colour_description_present_flag << 24) & 0x1000000) |
- ((full_range << 25) & 0x2000000) |
- ((video_format << 26) & 0x1C000000) |
- ((video_signal_type_present_flag << 29) & 0x20000000);
- i_vpr_h(inst, "%s: color info: %#x\n", __func__, payload);
- rc = venus_hfi_session_property(inst,
- HFI_PROP_SIGNAL_COLOR_INFO,
- HFI_HOST_FLAGS_NONE,
- get_hfi_port(inst, port),
- HFI_PAYLOAD_32_PACKED,
- &payload,
- sizeof(u32));
- if (rc)
- return rc;
- return 0;
- }
- static bool msm_venc_csc_required(struct msm_vidc_inst* inst)
- {
- struct v4l2_format *in_fmt = &inst->fmts[INPUT_PORT];
- struct v4l2_format *out_fmt = &inst->fmts[OUTPUT_PORT];
- /* video hardware supports conversion to REC709 CSC only */
- if (in_fmt->fmt.pix_mp.colorspace != out_fmt->fmt.pix_mp.colorspace &&
- out_fmt->fmt.pix_mp.colorspace == V4L2_COLORSPACE_REC709)
- return true;
- return false;
- }
- static int msm_venc_set_csc(struct msm_vidc_inst* inst,
- enum msm_vidc_port_type port)
- {
- int rc = 0;
- u32 csc = 0;
- if (port != OUTPUT_PORT) {
- i_vpr_e(inst, "%s: invalid port %d\n", __func__, port);
- return -EINVAL;
- }
- msm_vidc_update_cap_value(inst, CSC,
- msm_venc_csc_required(inst) ? 1 : 0, __func__);
- csc = inst->capabilities->cap[CSC].value;
- i_vpr_h(inst, "%s: csc: %u\n", __func__, csc);
- rc = venus_hfi_session_property(inst,
- HFI_PROP_CSC,
- HFI_HOST_FLAGS_NONE,
- get_hfi_port(inst, port),
- HFI_PAYLOAD_U32,
- &csc,
- sizeof(u32));
- if (rc)
- return rc;
- return 0;
- }
- static int msm_venc_set_quality_mode(struct msm_vidc_inst *inst)
- {
- int rc = 0;
- struct msm_vidc_core* core = inst->core;
- struct msm_vidc_inst_capability *capability = inst->capabilities;
- u32 mode;
- rc = call_session_op(core, decide_quality_mode, inst);
- if (rc) {
- i_vpr_e(inst, "%s: decide_work_route failed\n",
- __func__);
- return -EINVAL;
- }
- mode = capability->cap[QUALITY_MODE].value;
- i_vpr_h(inst, "%s: quality_mode: %u\n", __func__, mode);
- rc = venus_hfi_session_property(inst,
- HFI_PROP_QUALITY_MODE,
- HFI_HOST_FLAGS_NONE,
- HFI_PORT_BITSTREAM,
- HFI_PAYLOAD_U32_ENUM,
- &mode,
- sizeof(u32));
- if (rc)
- return rc;
- return 0;
- }
- static int msm_venc_set_input_properties(struct msm_vidc_inst *inst)
- {
- int i, j, rc = 0;
- static const struct msm_venc_prop_type_handle prop_type_handle_arr[] = {
- {HFI_PROP_COLOR_FORMAT, msm_venc_set_colorformat },
- {HFI_PROP_RAW_RESOLUTION, msm_venc_set_raw_resolution },
- {HFI_PROP_LINEAR_STRIDE_SCANLINE, msm_venc_set_stride_scanline },
- {HFI_PROP_SIGNAL_COLOR_INFO, msm_venc_set_colorspace },
- };
- if (!inst) {
- d_vpr_e("%s: invalid params\n", __func__);
- return -EINVAL;
- }
- i_vpr_h(inst, "%s()\n", __func__);
- for (i = 0; i < ARRAY_SIZE(msm_venc_input_set_prop); i++) {
- /* set session input properties */
- for (j = 0; j < ARRAY_SIZE(prop_type_handle_arr); j++) {
- if (prop_type_handle_arr[j].type == msm_venc_input_set_prop[i]) {
- rc = prop_type_handle_arr[j].handle(inst, INPUT_PORT);
- if (rc)
- goto exit;
- break;
- }
- }
- /* is property type unknown ? */
- if (j == ARRAY_SIZE(prop_type_handle_arr))
- i_vpr_e(inst, "%s: unknown property %#x\n", __func__,
- msm_venc_input_set_prop[i]);
- }
- exit:
- return rc;
- }
- static int msm_venc_set_output_properties(struct msm_vidc_inst *inst)
- {
- int i, j, rc = 0;
- static const struct msm_venc_prop_type_handle prop_type_handle_arr[] = {
- {HFI_PROP_BITSTREAM_RESOLUTION, msm_venc_set_bitstream_resolution },
- {HFI_PROP_CROP_OFFSETS, msm_venc_set_crop_offsets },
- {HFI_PROP_CSC, msm_venc_set_csc },
- };
- if (!inst) {
- d_vpr_e("%s: invalid params\n", __func__);
- return -EINVAL;
- }
- i_vpr_h(inst, "%s()\n", __func__);
- for (i = 0; i < ARRAY_SIZE(msm_venc_output_set_prop); i++) {
- /* set session output properties */
- for (j = 0; j < ARRAY_SIZE(prop_type_handle_arr); j++) {
- if (prop_type_handle_arr[j].type == msm_venc_output_set_prop[i]) {
- rc = prop_type_handle_arr[j].handle(inst, OUTPUT_PORT);
- if (rc)
- goto exit;
- break;
- }
- }
- /* is property type unknown ? */
- if (j == ARRAY_SIZE(prop_type_handle_arr))
- i_vpr_e(inst, "%s: unknown property %#x\n", __func__,
- msm_venc_output_set_prop[i]);
- }
- exit:
- return rc;
- }
- static int msm_venc_set_internal_properties(struct msm_vidc_inst *inst)
- {
- int rc = 0;
- if (!inst) {
- d_vpr_e("%s: invalid params\n", __func__);
- return -EINVAL;
- }
- i_vpr_h(inst, "%s()\n", __func__);
- rc = msm_venc_set_quality_mode(inst);
- if (rc)
- return rc;
- return rc;
- }
- static int msm_venc_get_input_internal_buffers(struct msm_vidc_inst *inst)
- {
- int i, rc = 0;
- if (!inst) {
- d_vpr_e("%s: invalid params\n", __func__);
- return -EINVAL;
- }
- for (i = 0; i < ARRAY_SIZE(msm_venc_input_internal_buffer_type); i++) {
- rc = msm_vidc_get_internal_buffers(inst,
- msm_venc_input_internal_buffer_type[i]);
- if (rc)
- return rc;
- }
- return rc;
- }
- static int msm_venc_create_input_internal_buffers(struct msm_vidc_inst *inst)
- {
- int i, rc = 0;
- if (!inst || !inst->core) {
- d_vpr_e("%s: invalid params\n", __func__);
- return -EINVAL;
- }
- for (i = 0; i < ARRAY_SIZE(msm_venc_input_internal_buffer_type); i++) {
- rc = msm_vidc_create_internal_buffers(inst,
- msm_venc_input_internal_buffer_type[i]);
- if (rc)
- return rc;
- }
- return rc;
- }
- static int msm_venc_queue_input_internal_buffers(struct msm_vidc_inst *inst)
- {
- int i, rc = 0;
- if (!inst || !inst->core) {
- d_vpr_e("%s: invalid params\n", __func__);
- return -EINVAL;
- }
- for (i = 0; i < ARRAY_SIZE(msm_venc_input_internal_buffer_type); i++) {
- rc = msm_vidc_queue_internal_buffers(inst,
- msm_venc_input_internal_buffer_type[i]);
- if (rc)
- return rc;
- }
- return rc;
- }
- static int msm_venc_get_output_internal_buffers(struct msm_vidc_inst *inst)
- {
- int i, rc = 0;
- struct msm_vidc_core *core;
- if (!inst || !inst->core) {
- d_vpr_e("%s: invalid params\n", __func__);
- return -EINVAL;
- }
- core = inst->core;
- for (i = 0; i < ARRAY_SIZE(msm_venc_output_internal_buffer_type); i++) {
- rc = msm_vidc_get_internal_buffers(inst,
- msm_venc_output_internal_buffer_type[i]);
- if (rc)
- return rc;
- }
- return rc;
- }
- static int msm_venc_create_output_internal_buffers(struct msm_vidc_inst *inst)
- {
- int i, rc = 0;
- if (!inst || !inst->core) {
- d_vpr_e("%s: invalid params\n", __func__);
- return -EINVAL;
- }
- for (i = 0; i < ARRAY_SIZE(msm_venc_output_internal_buffer_type); i++) {
- rc = msm_vidc_create_internal_buffers(inst,
- msm_venc_output_internal_buffer_type[i]);
- if (rc)
- return rc;
- }
- return 0;
- }
- static int msm_venc_queue_output_internal_buffers(struct msm_vidc_inst *inst)
- {
- int i, rc = 0;
- if (!inst || !inst->core) {
- d_vpr_e("%s: invalid params\n", __func__);
- return -EINVAL;
- }
- for (i = 0; i < ARRAY_SIZE(msm_venc_output_internal_buffer_type); i++) {
- rc = msm_vidc_queue_internal_buffers(inst,
- msm_venc_output_internal_buffer_type[i]);
- if (rc)
- return rc;
- }
- return 0;
- }
- static int msm_venc_property_subscription(struct msm_vidc_inst *inst,
- enum msm_vidc_port_type port)
- {
- int rc = 0;
- u32 payload[32] = {0};
- u32 i;
- u32 payload_size = 0;
- if (!inst) {
- d_vpr_e("%s: invalid params\n", __func__);
- return -EINVAL;
- }
- i_vpr_h(inst, "%s()\n", __func__);
- payload[0] = HFI_MODE_PROPERTY;
- if (port == INPUT_PORT) {
- for (i = 0; i < ARRAY_SIZE(msm_venc_input_subscribe_for_properties); i++)
- payload[i + 1] = msm_venc_input_subscribe_for_properties[i];
- payload_size = (ARRAY_SIZE(msm_venc_input_subscribe_for_properties) + 1) *
- sizeof(u32);
- } else if (port == OUTPUT_PORT) {
- for (i = 0; i < ARRAY_SIZE(msm_venc_output_subscribe_for_properties); i++)
- payload[i + 1] = msm_venc_output_subscribe_for_properties[i];
- payload_size = (ARRAY_SIZE(msm_venc_output_subscribe_for_properties) + 1) *
- sizeof(u32);
- } else {
- i_vpr_e(inst, "%s: invalid port: %d\n", __func__, port);
- return -EINVAL;
- }
- rc = venus_hfi_session_command(inst,
- HFI_CMD_SUBSCRIBE_MODE,
- port,
- HFI_PAYLOAD_U32_ARRAY,
- &payload[0],
- payload_size);
- if (rc)
- return rc;
- return rc;
- }
- static int msm_venc_metadata_delivery(struct msm_vidc_inst *inst,
- enum msm_vidc_port_type port)
- {
- int rc = 0;
- struct msm_vidc_core *core;
- u32 payload[32] = {0};
- u32 i, count = 0;
- struct msm_vidc_inst_capability *capability;
- if (!inst || !inst->core) {
- d_vpr_e("%s: invalid params\n", __func__);
- return -EINVAL;
- }
- core = inst->core;
- i_vpr_h(inst, "%s()\n", __func__);
- capability = inst->capabilities;
- payload[0] = HFI_MODE_METADATA;
- if (port == INPUT_PORT) {
- for (i = INST_CAP_NONE + 1; i < META_CAP_MAX; i++) {
- if (is_meta_tx_inp_enabled(inst, i)) {
- payload[count + 1] = capability->cap[i].hfi_id;
- count++;
- }
- }
- } else if (port == OUTPUT_PORT) {
- for (i = INST_CAP_NONE + 1; i < META_CAP_MAX; i++) {
- if (is_meta_tx_out_enabled(inst, i)) {
- payload[count + 1] = capability->cap[i].hfi_id;
- count++;
- }
- }
- } else {
- i_vpr_e(inst, "%s: invalid port: %d\n", __func__, port);
- return -EINVAL;
- }
- rc = venus_hfi_session_command(inst,
- HFI_CMD_DELIVERY_MODE,
- port,
- HFI_PAYLOAD_U32_ARRAY,
- &payload[0],
- (count + 1) * sizeof(u32));
- if (rc)
- return rc;
- return rc;
- }
- static int msm_venc_metadata_subscription(struct msm_vidc_inst *inst,
- enum msm_vidc_port_type port)
- {
- int rc = 0;
- u32 payload[32] = {0};
- u32 i, count = 0;
- struct msm_vidc_inst_capability *capability;
- if (!inst) {
- d_vpr_e("%s: invalid params\n", __func__);
- return -EINVAL;
- }
- i_vpr_h(inst, "%s()\n", __func__);
- capability = inst->capabilities;
- payload[0] = HFI_MODE_METADATA;
- if (port == INPUT_PORT) {
- for (i = INST_CAP_NONE + 1; i < META_CAP_MAX; i++) {
- if (is_meta_rx_inp_enabled(inst, i)) {
- payload[count + 1] = capability->cap[i].hfi_id;
- count++;
- }
- }
- } else if (port == OUTPUT_PORT) {
- for (i = INST_CAP_NONE + 1; i < META_CAP_MAX; i++) {
- if (is_meta_rx_out_enabled(inst, i)) {
- payload[count + 1] = capability->cap[i].hfi_id;
- count++;
- }
- }
- } else {
- i_vpr_e(inst, "%s: invalid port: %d\n", __func__, port);
- return -EINVAL;
- }
- rc = venus_hfi_session_command(inst,
- HFI_CMD_SUBSCRIBE_MODE,
- port,
- HFI_PAYLOAD_U32_ARRAY,
- &payload[0],
- (count + 1) * sizeof(u32));
- if (rc)
- return rc;
- return rc;
- }
- int msm_venc_streamoff_input(struct msm_vidc_inst *inst)
- {
- int rc = 0;
- if (!inst || !inst->core || !inst->capabilities) {
- d_vpr_e("%s: invalid params\n", __func__);
- return -EINVAL;
- }
- rc = msm_vidc_session_streamoff(inst, INPUT_PORT);
- if (rc)
- return rc;
- return 0;
- }
- int msm_venc_streamon_input(struct msm_vidc_inst *inst)
- {
- int rc = 0;
- if (!inst || !inst->core || !inst->capabilities) {
- d_vpr_e("%s: invalid params\n", __func__);
- return -EINVAL;
- }
- /*
- * do not check for input meta port streamon when
- * request is enabled
- */
- if (!inst->capabilities->cap[INPUT_META_VIA_REQUEST].value) {
- if (is_input_meta_enabled(inst) &&
- !inst->bufq[INPUT_META_PORT].vb2q->streaming) {
- i_vpr_e(inst,
- "%s: Meta port must be streamed on before data port\n",
- __func__);
- return -EINVAL;
- }
- }
- rc = msm_vidc_check_session_supported(inst);
- if (rc)
- goto error;
- rc = msm_vidc_check_scaling_supported(inst);
- if (rc)
- goto error;
- rc = msm_venc_set_input_properties(inst);
- if (rc)
- goto error;
- /* Decide bse vpp delay after work mode */
- //msm_vidc_set_bse_vpp_delay(inst);
- rc = msm_venc_get_input_internal_buffers(inst);
- if (rc)
- goto error;
- rc = msm_venc_create_input_internal_buffers(inst);
- if (rc)
- goto error;
- rc = msm_venc_queue_input_internal_buffers(inst);
- if (rc)
- goto error;
- rc = msm_venc_property_subscription(inst, INPUT_PORT);
- if (rc)
- goto error;
- rc = msm_venc_metadata_delivery(inst, INPUT_PORT);
- if (rc)
- goto error;
- rc = msm_vidc_process_streamon_input(inst);
- if (rc)
- goto error;
- return 0;
- error:
- i_vpr_e(inst, "%s: failed\n", __func__);
- msm_venc_streamoff_input(inst);
- return rc;
- }
- int msm_venc_qbuf(struct msm_vidc_inst *inst, struct vb2_buffer *vb2)
- {
- int rc = 0;
- if (!inst || !inst->capabilities) {
- d_vpr_e("%s: invalid params\n", __func__);
- return -EINVAL;
- }
- rc = msm_vidc_queue_buffer_single(inst, vb2);
- if (rc)
- return rc;
- return rc;
- }
- int msm_venc_process_cmd(struct msm_vidc_inst *inst, u32 cmd)
- {
- int rc = 0;
- enum msm_vidc_allow allow = MSM_VIDC_DISALLOW;
- if (!inst || !inst->core) {
- d_vpr_e("%s: invalid params\n", __func__);
- return -EINVAL;
- }
- if (cmd == V4L2_ENC_CMD_STOP) {
- i_vpr_h(inst, "received cmd: drain\n");
- allow = msm_vidc_allow_stop(inst);
- if (allow == MSM_VIDC_DISALLOW)
- return -EBUSY;
- else if (allow == MSM_VIDC_IGNORE)
- return 0;
- else if (allow != MSM_VIDC_ALLOW)
- return -EINVAL;
- rc = msm_vidc_process_drain(inst);
- if (rc)
- return rc;
- } else if (cmd == V4L2_ENC_CMD_START) {
- i_vpr_h(inst, "received cmd: resume\n");
- if (!msm_vidc_allow_start(inst))
- return -EBUSY;
- vb2_clear_last_buffer_dequeued(inst->bufq[OUTPUT_META_PORT].vb2q);
- vb2_clear_last_buffer_dequeued(inst->bufq[OUTPUT_PORT].vb2q);
- /* tune power features */
- msm_vidc_allow_dcvs(inst);
- msm_vidc_power_data_reset(inst);
- /* print final buffer counts & size details */
- msm_vidc_print_buffer_info(inst);
- rc = msm_vidc_process_resume(inst);
- if (rc)
- return rc;
- } else {
- i_vpr_e(inst, "%s: unknown cmd %d\n", __func__, cmd);
- return -EINVAL;
- }
- return 0;
- }
- int msm_venc_streamoff_output(struct msm_vidc_inst *inst)
- {
- int rc = 0;
- struct msm_vidc_core *core;
- if (!inst || !inst->core || !inst->capabilities) {
- d_vpr_e("%s: invalid params\n", __func__);
- return -EINVAL;
- }
- core = inst->core;
- if (!core->capabilities) {
- i_vpr_e(inst, "%s: core capabilities is NULL\n", __func__);
- return -EINVAL;
- }
- /* restore LAYER_COUNT max allowed value */
- inst->capabilities->cap[ENH_LAYER_COUNT].max =
- core->capabilities[MAX_ENH_LAYER_COUNT].value;
- rc = msm_vidc_session_streamoff(inst, OUTPUT_PORT);
- if (rc)
- return rc;
- return 0;
- }
- int msm_venc_streamon_output(struct msm_vidc_inst *inst)
- {
- int rc = 0;
- if (!inst || !inst->core || !inst->capabilities) {
- d_vpr_e("%s: invalid params\n", __func__);
- return -EINVAL;
- }
- if (is_output_meta_enabled(inst) &&
- !inst->bufq[OUTPUT_META_PORT].vb2q->streaming) {
- i_vpr_e(inst,
- "%s: Meta port must be streamed on before data port\n",
- __func__);
- return -EINVAL;
- }
- rc = msm_venc_set_output_properties(inst);
- if (rc)
- goto error;
- rc = msm_vidc_adjust_set_v4l2_properties(inst);
- if (rc)
- goto error;
- rc = msm_venc_get_output_internal_buffers(inst);
- if (rc)
- goto error;
- rc = msm_venc_create_output_internal_buffers(inst);
- if (rc)
- goto error;
- rc = msm_venc_queue_output_internal_buffers(inst);
- if (rc)
- goto error;
- rc = msm_venc_set_internal_properties(inst);
- if (rc)
- goto error;
- rc = msm_venc_property_subscription(inst, OUTPUT_PORT);
- if (rc)
- goto error;
- rc = msm_venc_metadata_subscription(inst, OUTPUT_PORT);
- if (rc)
- goto error;
- rc = msm_vidc_process_streamon_output(inst);
- if (rc)
- goto error;
- return 0;
- error:
- i_vpr_e(inst, "%s: failed\n", __func__);
- msm_venc_streamoff_output(inst);
- return rc;
- }
- int msm_venc_try_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
- {
- int rc = 0;
- struct v4l2_pix_format_mplane *pixmp = &f->fmt.pix_mp;
- u32 pix_fmt;
- if (!inst) {
- d_vpr_e("%s: invalid params\n", __func__);
- return -EINVAL;
- }
- memset(pixmp->reserved, 0, sizeof(pixmp->reserved));
- if (f->type == INPUT_MPLANE) {
- pix_fmt = v4l2_colorformat_to_driver(f->fmt.pix_mp.pixelformat, __func__);
- if (!pix_fmt) {
- i_vpr_e(inst, "%s: unsupported format, set current params\n", __func__);
- f->fmt.pix_mp.pixelformat = inst->fmts[INPUT_PORT].fmt.pix_mp.pixelformat;
- f->fmt.pix_mp.width = inst->fmts[INPUT_PORT].fmt.pix_mp.width;
- f->fmt.pix_mp.height = inst->fmts[INPUT_PORT].fmt.pix_mp.height;
- pix_fmt = v4l2_colorformat_to_driver(f->fmt.pix_mp.pixelformat, __func__);
- }
- } else if (f->type == OUTPUT_MPLANE) {
- pix_fmt = v4l2_codec_to_driver(f->fmt.pix_mp.pixelformat, __func__);
- if (!pix_fmt) {
- i_vpr_e(inst, "%s: unsupported codec, set current params\n", __func__);
- f->fmt.pix_mp.width = inst->fmts[OUTPUT_PORT].fmt.pix_mp.width;
- f->fmt.pix_mp.height = inst->fmts[OUTPUT_PORT].fmt.pix_mp.height;
- f->fmt.pix_mp.pixelformat = inst->fmts[OUTPUT_PORT].fmt.pix_mp.pixelformat;
- pix_fmt = v4l2_codec_to_driver(f->fmt.pix_mp.pixelformat, __func__);
- }
- } else if (f->type == INPUT_META_PLANE) {
- f->fmt.meta.dataformat = inst->fmts[INPUT_META_PORT].fmt.meta.dataformat;
- f->fmt.meta.buffersize = inst->fmts[INPUT_META_PORT].fmt.meta.buffersize;
- } else if (f->type == OUTPUT_META_PLANE) {
- f->fmt.meta.dataformat = inst->fmts[OUTPUT_META_PORT].fmt.meta.dataformat;
- f->fmt.meta.buffersize = inst->fmts[OUTPUT_META_PORT].fmt.meta.buffersize;
- } else {
- i_vpr_e(inst, "%s: invalid type %d\n", __func__, f->type);
- return -EINVAL;
- }
- if (pixmp->field == V4L2_FIELD_ANY)
- pixmp->field = V4L2_FIELD_NONE;
- pixmp->num_planes = 1;
- return rc;
- }
- int msm_venc_s_fmt_output(struct msm_vidc_inst *inst, struct v4l2_format *f)
- {
- int rc = 0;
- struct v4l2_format *fmt;
- struct msm_vidc_core *core;
- u32 codec_align;
- u32 width, height;
- if (!inst || !inst->core || !f) {
- d_vpr_e("%s: invalid params\n", __func__);
- return -EINVAL;
- }
- core = inst->core;
- msm_venc_try_fmt(inst, f);
- fmt = &inst->fmts[OUTPUT_PORT];
- if (fmt->fmt.pix_mp.pixelformat != f->fmt.pix_mp.pixelformat) {
- rc = msm_venc_codec_change(inst, f->fmt.pix_mp.pixelformat);
- if (rc)
- return rc;
- }
- fmt->type = OUTPUT_MPLANE;
- codec_align = (f->fmt.pix_mp.pixelformat == V4L2_PIX_FMT_HEVC ||
- f->fmt.pix_mp.pixelformat == V4L2_PIX_FMT_HEIC) ? 32 : 16;
- /* use rotated width height if rotation is enabled */
- width = inst->compose.width;
- height = inst->compose.height;
- if (is_rotation_90_or_270(inst)) {
- width = inst->compose.height;
- height = inst->compose.width;
- }
- /* width, height is readonly for client */
- fmt->fmt.pix_mp.width = ALIGN(width, codec_align);
- fmt->fmt.pix_mp.height = ALIGN(height, codec_align);
- /* use grid dimension for image session */
- if (is_image_session(inst))
- fmt->fmt.pix_mp.width = fmt->fmt.pix_mp.height = HEIC_GRID_DIMENSION;
- fmt->fmt.pix_mp.num_planes = 1;
- fmt->fmt.pix_mp.plane_fmt[0].bytesperline = 0;
- fmt->fmt.pix_mp.plane_fmt[0].sizeimage = call_session_op(core,
- buffer_size, inst, MSM_VIDC_BUF_OUTPUT);
- /* video hw supports conversion to V4L2_COLORSPACE_REC709 only */
- if (f->fmt.pix_mp.colorspace != V4L2_COLORSPACE_DEFAULT &&
- f->fmt.pix_mp.colorspace != V4L2_COLORSPACE_REC709)
- f->fmt.pix_mp.colorspace = V4L2_COLORSPACE_DEFAULT;
- fmt->fmt.pix_mp.colorspace = f->fmt.pix_mp.colorspace;
- fmt->fmt.pix_mp.xfer_func = f->fmt.pix_mp.xfer_func;
- fmt->fmt.pix_mp.ycbcr_enc = f->fmt.pix_mp.ycbcr_enc;
- fmt->fmt.pix_mp.quantization = f->fmt.pix_mp.quantization;
- inst->buffers.output.min_count = call_session_op(core,
- min_count, inst, MSM_VIDC_BUF_OUTPUT);
- inst->buffers.output.extra_count = call_session_op(core,
- extra_count, inst, MSM_VIDC_BUF_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_mp.plane_fmt[0].sizeimage;
- /* reset metadata buffer size with updated resolution*/
- msm_vidc_update_meta_port_settings(inst);
- i_vpr_h(inst,
- "%s: type: OUTPUT, codec %s width %d height %d size %u min_count %d extra_count %d\n",
- __func__, v4l2_pixelfmt_name(fmt->fmt.pix_mp.pixelformat),
- fmt->fmt.pix_mp.width, fmt->fmt.pix_mp.height,
- fmt->fmt.pix_mp.plane_fmt[0].sizeimage,
- inst->buffers.output.min_count,
- inst->buffers.output.extra_count);
- /* finally update client format */
- memcpy(f, fmt, sizeof(struct v4l2_format));
- return rc;
- }
- static int msm_venc_s_fmt_output_meta(struct msm_vidc_inst *inst, struct v4l2_format *f)
- {
- int rc = 0;
- struct v4l2_format *fmt;
- struct msm_vidc_core *core;
- if (!inst || !inst->core) {
- d_vpr_e("%s: invalid params\n", __func__);
- return -EINVAL;
- }
- core = inst->core;
- fmt = &inst->fmts[OUTPUT_META_PORT];
- fmt->type = OUTPUT_META_PLANE;
- fmt->fmt.meta.dataformat = V4L2_META_FMT_VIDC;
- fmt->fmt.meta.buffersize = call_session_op(core,
- buffer_size, inst, MSM_VIDC_BUF_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;
- memcpy(f, fmt, sizeof(struct v4l2_format));
- i_vpr_h(inst, "%s: type: OUTPUT_META, size %u min_count %d extra_count %d\n",
- __func__, fmt->fmt.meta.buffersize,
- inst->buffers.output_meta.min_count,
- inst->buffers.output_meta.extra_count);
- return rc;
- }
- static int msm_venc_s_fmt_input(struct msm_vidc_inst *inst, struct v4l2_format *f)
- {
- int rc = 0;
- struct v4l2_format *fmt, *output_fmt;
- struct msm_vidc_core *core;
- u32 pix_fmt, width, height, size, bytesperline;
- if (!inst || !inst->core || !inst->capabilities) {
- d_vpr_e("%s: invalid params\n", __func__);
- return -EINVAL;
- }
- core = inst->core;
- msm_venc_try_fmt(inst, f);
- pix_fmt = v4l2_colorformat_to_driver(f->fmt.pix_mp.pixelformat, __func__);
- msm_vidc_update_cap_value(inst, PIX_FMTS, pix_fmt, __func__);
- width = f->fmt.pix_mp.width;
- height = f->fmt.pix_mp.height;
- if (is_image_session(inst)) {
- bytesperline = ALIGN(f->fmt.pix_mp.width, HEIC_GRID_DIMENSION) *
- (is_10bit_colorformat(pix_fmt) ? 2 : 1);
- } else if (is_rgba_colorformat(pix_fmt)) {
- bytesperline = video_rgb_stride_bytes(pix_fmt, f->fmt.pix_mp.width);
- } else {
- bytesperline = video_y_stride_bytes(pix_fmt, f->fmt.pix_mp.width);
- }
- fmt = &inst->fmts[INPUT_PORT];
- fmt->type = INPUT_MPLANE;
- fmt->fmt.pix_mp.width = width;
- fmt->fmt.pix_mp.height = height;
- fmt->fmt.pix_mp.num_planes = 1;
- fmt->fmt.pix_mp.pixelformat = f->fmt.pix_mp.pixelformat;
- fmt->fmt.pix_mp.plane_fmt[0].bytesperline = bytesperline;
- if (is_image_session(inst))
- size = bytesperline * height * 3 / 2;
- else
- size = call_session_op(core, buffer_size, inst, MSM_VIDC_BUF_INPUT);
- fmt->fmt.pix_mp.plane_fmt[0].sizeimage = size;
- /* update input port colorspace info */
- fmt->fmt.pix_mp.colorspace = f->fmt.pix_mp.colorspace;
- fmt->fmt.pix_mp.xfer_func = f->fmt.pix_mp.xfer_func;
- fmt->fmt.pix_mp.ycbcr_enc = f->fmt.pix_mp.ycbcr_enc;
- fmt->fmt.pix_mp.quantization = f->fmt.pix_mp.quantization;
- /*
- * Update output port colorspace info.
- * NOTE: If client needs CSC, then client needs to ensure setting
- * output port color after setting input color info.
- */
- output_fmt = &inst->fmts[OUTPUT_PORT];
- output_fmt->fmt.pix_mp.colorspace = fmt->fmt.pix_mp.colorspace;
- output_fmt->fmt.pix_mp.xfer_func = fmt->fmt.pix_mp.xfer_func;
- output_fmt->fmt.pix_mp.ycbcr_enc = fmt->fmt.pix_mp.ycbcr_enc;
- output_fmt->fmt.pix_mp.quantization = fmt->fmt.pix_mp.quantization;
- inst->buffers.input.min_count = call_session_op(core,
- min_count, inst, MSM_VIDC_BUF_INPUT);
- inst->buffers.input.extra_count = call_session_op(core,
- extra_count, inst, MSM_VIDC_BUF_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 = size;
- if (f->fmt.pix_mp.width != inst->crop.width ||
- f->fmt.pix_mp.height != inst->crop.height) {
- /* reset crop dimensions with updated resolution */
- inst->crop.top = inst->crop.left = 0;
- inst->crop.width = f->fmt.pix_mp.width;
- inst->crop.height = f->fmt.pix_mp.height;
- /* reset compose dimensions with updated resolution */
- inst->compose.top = inst->compose.left = 0;
- inst->compose.width = f->fmt.pix_mp.width;
- inst->compose.height = f->fmt.pix_mp.height;
- /* update output format */
- rc = msm_venc_s_fmt_output(inst, output_fmt);
- if (rc)
- return rc;
- }
- /* reset metadata buffer size with updated resolution*/
- msm_vidc_update_meta_port_settings(inst);
- i_vpr_h(inst,
- "%s: type: INPUT, format %s width %d height %d size %u min_count %d extra_count %d\n",
- __func__, v4l2_pixelfmt_name(fmt->fmt.pix_mp.pixelformat),
- fmt->fmt.pix_mp.width, fmt->fmt.pix_mp.height,
- fmt->fmt.pix_mp.plane_fmt[0].sizeimage,
- inst->buffers.input.min_count,
- inst->buffers.input.extra_count);
- /* finally update client format */
- memcpy(f, fmt, sizeof(struct v4l2_format));
- return rc;
- }
- static int msm_venc_s_fmt_input_meta(struct msm_vidc_inst *inst, struct v4l2_format *f)
- {
- int rc = 0;
- struct v4l2_format *fmt;
- struct msm_vidc_core *core;
- if (!inst || !inst->core) {
- d_vpr_e("%s: invalid params\n", __func__);
- return -EINVAL;
- }
- core = inst->core;
- fmt = &inst->fmts[INPUT_META_PORT];
- fmt->type = INPUT_META_PLANE;
- fmt->fmt.meta.dataformat = V4L2_META_FMT_VIDC;
- fmt->fmt.meta.buffersize = call_session_op(core,
- buffer_size, inst, MSM_VIDC_BUF_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;
- memcpy(f, fmt, sizeof(struct v4l2_format));
- i_vpr_h(inst, "%s: type: INPUT_META, size %u min_count %d extra_count %d\n",
- __func__, fmt->fmt.meta.buffersize,
- inst->buffers.input_meta.min_count,
- inst->buffers.input_meta.extra_count);
- return rc;
- }
- int msm_venc_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
- {
- int rc = 0;
- if (!inst) {
- d_vpr_e("%s: invalid params\n", __func__);
- return -EINVAL;
- }
- if (f->type == INPUT_MPLANE) {
- rc = msm_venc_s_fmt_input(inst, f);
- if (rc)
- goto exit;
- } else if (f->type == INPUT_META_PLANE) {
- rc = msm_venc_s_fmt_input_meta(inst, f);
- if (rc)
- goto exit;
- } else if (f->type == OUTPUT_MPLANE) {
- rc = msm_venc_s_fmt_output(inst, f);
- if (rc)
- goto exit;
- } else if (f->type == OUTPUT_META_PLANE) {
- rc = msm_venc_s_fmt_output_meta(inst, f);
- if (rc)
- goto exit;
- } else {
- i_vpr_e(inst, "%s: invalid type %d\n", __func__, f->type);
- rc = -EINVAL;
- goto exit;
- }
- exit:
- if (rc)
- i_vpr_e(inst, "%s: failed\n", __func__);
- return rc;
- }
- int msm_venc_g_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
- {
- int rc = 0;
- int port;
- if (!inst) {
- d_vpr_e("%s: invalid params\n", __func__);
- return -EINVAL;
- }
- port = v4l2_type_to_driver_port(inst, f->type, __func__);
- if (port < 0)
- return -EINVAL;
- memcpy(f, &inst->fmts[port], sizeof(struct v4l2_format));
- return rc;
- }
- int msm_venc_s_selection(struct msm_vidc_inst* inst, struct v4l2_selection* s)
- {
- int rc = 0;
- struct v4l2_format *output_fmt;
- if (!inst || !s) {
- d_vpr_e("%s: invalid params\n", __func__);
- return -EINVAL;
- }
- if (s->type != INPUT_MPLANE && s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) {
- i_vpr_e(inst, "%s: invalid type %d\n", __func__, s->type);
- return -EINVAL;
- }
- switch (s->target) {
- case V4L2_SEL_TGT_CROP:
- if (s->r.left || s->r.top) {
- i_vpr_h(inst, "%s: unsupported top %d or left %d\n",
- __func__, s->r.left, s->r.top);
- s->r.left = s->r.top = 0;
- }
- if (s->r.width > inst->fmts[INPUT_PORT].fmt.pix_mp.width) {
- i_vpr_h(inst, "%s: unsupported width %d, fmt width %d\n",
- __func__, s->r.width,
- inst->fmts[INPUT_PORT].fmt.pix_mp.width);
- s->r.width = inst->fmts[INPUT_PORT].fmt.pix_mp.width;
- }
- if (s->r.height > inst->fmts[INPUT_PORT].fmt.pix_mp.height) {
- i_vpr_h(inst, "%s: unsupported height %d, fmt height %d\n",
- __func__, s->r.height,
- inst->fmts[INPUT_PORT].fmt.pix_mp.height);
- s->r.height = inst->fmts[INPUT_PORT].fmt.pix_mp.height;
- }
- inst->crop.left = s->r.left;
- inst->crop.top = s->r.top;
- inst->crop.width = s->r.width;
- inst->crop.height = s->r.height;
- /* adjust compose such that it is within crop */
- inst->compose.left = inst->crop.left;
- inst->compose.top = inst->crop.top;
- inst->compose.width = inst->crop.width;
- inst->compose.height = inst->crop.height;
- /* update output format based on new crop dimensions */
- output_fmt = &inst->fmts[OUTPUT_PORT];
- rc = msm_venc_s_fmt_output(inst, output_fmt);
- if (rc)
- return rc;
- break;
- case V4L2_SEL_TGT_COMPOSE:
- if (s->r.left < inst->crop.left) {
- i_vpr_e(inst,
- "%s: compose left (%d) less than crop left (%d)\n",
- __func__, s->r.left, inst->crop.left);
- s->r.left = inst->crop.left;
- }
- if (s->r.top < inst->crop.top) {
- i_vpr_e(inst,
- "%s: compose top (%d) less than crop top (%d)\n",
- __func__, s->r.top, inst->crop.top);
- s->r.top = inst->crop.top;
- }
- if (s->r.width > inst->crop.width) {
- i_vpr_e(inst,
- "%s: compose width (%d) greate than crop width (%d)\n",
- __func__, s->r.width, inst->crop.width);
- s->r.width = inst->crop.width;
- }
- if (s->r.height > inst->crop.height) {
- i_vpr_e(inst,
- "%s: compose height (%d) greate than crop height (%d)\n",
- __func__, s->r.height, inst->crop.height);
- s->r.height = inst->crop.height;
- }
- inst->compose.left = s->r.left;
- inst->compose.top = s->r.top;
- inst->compose.width = s->r.width;
- inst->compose.height= s->r.height;
- if (is_scaling_enabled(inst)) {
- i_vpr_h(inst,
- "%s: scaling enabled, crop: l %d t %d w %d h %d compose: l %d t %d w %d h %d\n",
- __func__, inst->crop.left, inst->crop.top,
- inst->crop.width, inst->crop.height,
- inst->compose.left, inst->compose.top,
- inst->compose.width, inst->compose.height);
- }
- /* update output format based on new compose dimensions */
- output_fmt = &inst->fmts[OUTPUT_PORT];
- rc = msm_venc_s_fmt_output(inst, output_fmt);
- if (rc)
- return rc;
- break;
- default:
- i_vpr_e(inst, "%s: invalid target %d\n",
- __func__, s->target);
- rc = -EINVAL;
- break;
- }
- if (!rc)
- i_vpr_h(inst, "%s: target %d, r [%d, %d, %d, %d]\n",
- __func__, s->target, s->r.top, s->r.left,
- s->r.width, s->r.height);
- return rc;
- }
- int msm_venc_g_selection(struct msm_vidc_inst* inst, struct v4l2_selection* s)
- {
- int rc = 0;
- if (!inst || !s) {
- d_vpr_e("%s: invalid params\n", __func__);
- return -EINVAL;
- }
- if (s->type != INPUT_MPLANE && s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) {
- i_vpr_e(inst, "%s: invalid type %d\n", __func__, s->type);
- return -EINVAL;
- }
- switch (s->target) {
- case V4L2_SEL_TGT_CROP_BOUNDS:
- case V4L2_SEL_TGT_CROP_DEFAULT:
- case V4L2_SEL_TGT_CROP:
- s->r.left = inst->crop.left;
- s->r.top = inst->crop.top;
- s->r.width = inst->crop.width;
- s->r.height = inst->crop.height;
- break;
- case V4L2_SEL_TGT_COMPOSE_BOUNDS:
- case V4L2_SEL_TGT_COMPOSE_PADDED:
- case V4L2_SEL_TGT_COMPOSE_DEFAULT:
- case V4L2_SEL_TGT_COMPOSE:
- s->r.left = inst->compose.left;
- s->r.top = inst->compose.top;
- s->r.width = inst->compose.width;
- s->r.height = inst->compose.height;
- break;
- default:
- i_vpr_e(inst, "%s: invalid target %d\n",
- __func__, s->target);
- rc = -EINVAL;
- break;
- }
- if (!rc)
- i_vpr_h(inst, "%s: target %d, r [%d, %d, %d, %d]\n",
- __func__, s->target, s->r.top, s->r.left,
- s->r.width, s->r.height);
- return rc;
- }
- int msm_venc_s_param(struct msm_vidc_inst *inst,
- struct v4l2_streamparm *s_parm)
- {
- int rc = 0;
- struct msm_vidc_inst_capability *capability = NULL;
- struct v4l2_fract *timeperframe = NULL;
- u32 q16_rate, max_rate, default_rate;
- u64 us_per_frame = 0, input_rate = 0;
- bool is_frame_rate = false;
- if (!inst || !s_parm) {
- d_vpr_e("%s: invalid params\n", __func__);
- return -EINVAL;
- }
- capability = inst->capabilities;
- if (s_parm->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
- timeperframe = &s_parm->parm.output.timeperframe;
- max_rate = capability->cap[OPERATING_RATE].max >> 16;
- default_rate = capability->cap[OPERATING_RATE].value >> 16;
- s_parm->parm.output.capability = V4L2_CAP_TIMEPERFRAME;
- } else {
- timeperframe = &s_parm->parm.capture.timeperframe;
- is_frame_rate = true;
- max_rate = capability->cap[FRAME_RATE].max >> 16;
- default_rate = capability->cap[FRAME_RATE].value >> 16;
- s_parm->parm.capture.capability = V4L2_CAP_TIMEPERFRAME;
- }
- if (!timeperframe->denominator || !timeperframe->numerator) {
- i_vpr_e(inst, "%s: type %s, invalid rate, update with default\n",
- __func__, v4l2_type_name(s_parm->type));
- if (!timeperframe->numerator)
- timeperframe->numerator = 1;
- if (!timeperframe->denominator)
- timeperframe->denominator = default_rate;
- }
- us_per_frame = timeperframe->numerator * (u64)USEC_PER_SEC;
- do_div(us_per_frame, timeperframe->denominator);
- if (!us_per_frame) {
- i_vpr_e(inst, "%s: us_per_frame is zero\n", __func__);
- rc = -EINVAL;
- goto exit;
- }
- input_rate = (u64)USEC_PER_SEC;
- do_div(input_rate, us_per_frame);
- i_vpr_h(inst, "%s: type %s, %s value %llu\n",
- __func__, v4l2_type_name(s_parm->type),
- is_frame_rate ? "frame rate" : "operating rate", input_rate);
- q16_rate = (u32)input_rate << 16;
- msm_vidc_update_cap_value(inst, is_frame_rate ? FRAME_RATE : OPERATING_RATE,
- q16_rate, __func__);
- if (is_realtime_session(inst) &&
- ((s_parm->type == INPUT_MPLANE && inst->bufq[INPUT_PORT].vb2q->streaming) ||
- (s_parm->type == OUTPUT_MPLANE && inst->bufq[OUTPUT_PORT].vb2q->streaming))) {
- rc = msm_vidc_check_core_mbps(inst);
- if (rc) {
- i_vpr_e(inst, "%s: unsupported load\n", __func__);
- goto reset_rate;
- }
- rc = input_rate > max_rate;
- if (rc) {
- i_vpr_e(inst, "%s: unsupported rate %llu, max %u\n", __func__,
- input_rate, max_rate);
- rc = -ENOMEM;
- goto reset_rate;
- }
- }
- if (is_frame_rate)
- capability->cap[FRAME_RATE].flags |= CAP_FLAG_CLIENT_SET;
- else
- capability->cap[OPERATING_RATE].flags |= CAP_FLAG_CLIENT_SET;
- /*
- * In static case, frame rate is set via
- * inst database set function mentioned in
- * FRAME_RATE cap id.
- * In dynamic case, frame rate is set like below.
- */
- if (inst->bufq[OUTPUT_PORT].vb2q->streaming) {
- rc = venus_hfi_session_property(inst,
- HFI_PROP_FRAME_RATE,
- HFI_HOST_FLAGS_NONE,
- HFI_PORT_BITSTREAM,
- HFI_PAYLOAD_Q16,
- &q16_rate,
- sizeof(u32));
- if (rc) {
- i_vpr_e(inst,
- "%s: failed to set frame rate to fw\n", __func__);
- goto exit;
- }
- inst->auto_framerate = q16_rate;
- }
- return 0;
- reset_rate:
- if (rc) {
- i_vpr_e(inst, "%s: setting rate %llu failed, reset to %u\n", __func__,
- input_rate, default_rate);
- msm_vidc_update_cap_value(inst, is_frame_rate ? FRAME_RATE : OPERATING_RATE,
- default_rate << 16, __func__);
- }
- exit:
- return rc;
- }
- int msm_venc_g_param(struct msm_vidc_inst *inst,
- struct v4l2_streamparm *s_parm)
- {
- struct msm_vidc_inst_capability *capability = NULL;
- struct v4l2_fract *timeperframe = NULL;
- if (!inst || !s_parm) {
- d_vpr_e("%s: invalid params\n", __func__);
- return -EINVAL;
- }
- capability = inst->capabilities;
- if (s_parm->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
- timeperframe = &s_parm->parm.output.timeperframe;
- timeperframe->numerator = 1;
- timeperframe->denominator =
- capability->cap[OPERATING_RATE].value >> 16;
- s_parm->parm.output.capability = V4L2_CAP_TIMEPERFRAME;
- } else {
- timeperframe = &s_parm->parm.capture.timeperframe;
- timeperframe->numerator = 1;
- timeperframe->denominator =
- capability->cap[FRAME_RATE].value >> 16;
- s_parm->parm.capture.capability = V4L2_CAP_TIMEPERFRAME;
- }
- i_vpr_h(inst, "%s: type %s, num %u denom %u\n",
- __func__, v4l2_type_name(s_parm->type), timeperframe->numerator,
- timeperframe->denominator);
- return 0;
- }
- int msm_venc_subscribe_event(struct msm_vidc_inst *inst,
- const struct v4l2_event_subscription *sub)
- {
- int rc = 0;
- if (!inst || !sub) {
- d_vpr_e("%s: invalid params\n", __func__);
- return -EINVAL;
- }
- switch (sub->type) {
- case V4L2_EVENT_EOS:
- rc = v4l2_event_subscribe(&inst->event_handler, sub, MAX_EVENTS, NULL);
- break;
- case V4L2_EVENT_CTRL:
- rc = v4l2_ctrl_subscribe_event(&inst->event_handler, sub);
- break;
- default:
- i_vpr_e(inst, "%s: invalid type %d id %d\n", __func__, sub->type, sub->id);
- return -EINVAL;
- }
- if (rc)
- i_vpr_e(inst, "%s: failed, type %d id %d\n",
- __func__, sub->type, sub->id);
- return rc;
- }
- int msm_venc_enum_fmt(struct msm_vidc_inst *inst, struct v4l2_fmtdesc *f)
- {
- int rc = 0;
- struct msm_vidc_core *core;
- u32 array[32] = {0};
- u32 i = 0;
- if (!inst || !inst->core || !inst->capabilities || !f ||
- f->index >= ARRAY_SIZE(array)) {
- d_vpr_e("%s: invalid params\n", __func__);
- return -EINVAL;
- }
- core = inst->core;
- if (f->type == OUTPUT_MPLANE) {
- u32 codecs = core->capabilities[ENC_CODECS].value;
- u32 idx = 0;
- for (i = 0; i <= 31; i++) {
- if (codecs & BIT(i)) {
- if (idx >= ARRAY_SIZE(array))
- break;
- /* v4l2-compliance does not support private codecs */
- if ((codecs & BIT(i)) == MSM_VIDC_HEIC)
- continue;
- array[idx] = codecs & BIT(i);
- idx++;
- }
- }
- if (!array[f->index])
- return -EINVAL;
- f->pixelformat = v4l2_codec_from_driver(array[f->index],
- __func__);
- if (!f->pixelformat)
- return -EINVAL;
- f->flags = V4L2_FMT_FLAG_COMPRESSED;
- strlcpy(f->description, "codec", sizeof(f->description));
- } else if (f->type == INPUT_MPLANE) {
- u32 formats = inst->capabilities->cap[PIX_FMTS].step_or_mask;
- u32 idx = 0;
- for (i = 0; i <= 31; i++) {
- if (formats & BIT(i)) {
- if (idx >= ARRAY_SIZE(array))
- break;
- array[idx] = formats & BIT(i);
- idx++;
- }
- }
- if (!array[f->index])
- return -EINVAL;
- f->pixelformat = v4l2_colorformat_from_driver(array[f->index],
- __func__);
- if (!f->pixelformat)
- return -EINVAL;
- strlcpy(f->description, "colorformat", sizeof(f->description));
- } else if (f->type == INPUT_META_PLANE || f->type == OUTPUT_META_PLANE) {
- if (!f->index) {
- f->pixelformat = V4L2_META_FMT_VIDC;
- strlcpy(f->description, "metadata", sizeof(f->description));
- } else {
- return -EINVAL;
- }
- }
- memset(f->reserved, 0, sizeof(f->reserved));
- i_vpr_h(inst, "%s: index %d, %s: %s, flags %#x\n",
- __func__, f->index, f->description,
- v4l2_pixelfmt_name(f->pixelformat), f->flags);
- return rc;
- }
- int msm_venc_inst_init(struct msm_vidc_inst *inst)
- {
- int rc = 0;
- struct msm_vidc_core *core;
- struct v4l2_format *f;
- enum msm_vidc_colorformat_type colorformat;
- if (!inst || !inst->core) {
- d_vpr_e("%s: invalid params\n", __func__);
- return -EINVAL;
- }
- i_vpr_h(inst, "%s()\n", __func__);
- core = inst->core;
- if (core->capabilities[DCVS].value)
- inst->power.dcvs_mode = true;
- f = &inst->fmts[OUTPUT_PORT];
- f->type = OUTPUT_MPLANE;
- f->fmt.pix_mp.width = DEFAULT_WIDTH;
- f->fmt.pix_mp.height = DEFAULT_HEIGHT;
- f->fmt.pix_mp.pixelformat = V4L2_PIX_FMT_H264;
- f->fmt.pix_mp.num_planes = 1;
- f->fmt.pix_mp.plane_fmt[0].bytesperline = 0;
- f->fmt.pix_mp.plane_fmt[0].sizeimage = call_session_op(core,
- buffer_size, inst, MSM_VIDC_BUF_OUTPUT);
- f->fmt.pix_mp.field = V4L2_FIELD_NONE;
- f->fmt.pix_mp.colorspace = V4L2_COLORSPACE_DEFAULT;
- f->fmt.pix_mp.xfer_func = V4L2_XFER_FUNC_DEFAULT;
- f->fmt.pix_mp.ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT;
- f->fmt.pix_mp.quantization = V4L2_QUANTIZATION_DEFAULT;
- inst->buffers.output.min_count = call_session_op(core,
- min_count, inst, MSM_VIDC_BUF_OUTPUT);
- inst->buffers.output.extra_count = call_session_op(core,
- extra_count, inst, MSM_VIDC_BUF_OUTPUT);
- inst->buffers.output.actual_count =
- inst->buffers.output.min_count +
- inst->buffers.output.extra_count;
- inst->buffers.output.size = f->fmt.pix_mp.plane_fmt[0].sizeimage;
- inst->crop.left = inst->crop.top = 0;
- inst->crop.width = f->fmt.pix_mp.width;
- inst->crop.height = f->fmt.pix_mp.height;
- inst->compose.left = inst->compose.top = 0;
- inst->compose.width = f->fmt.pix_mp.width;
- inst->compose.height = f->fmt.pix_mp.height;
- f = &inst->fmts[OUTPUT_META_PORT];
- f->type = OUTPUT_META_PLANE;
- f->fmt.meta.dataformat = V4L2_META_FMT_VIDC;
- f->fmt.meta.buffersize = MSM_VIDC_METADATA_SIZE;
- inst->buffers.output_meta.min_count = 0;
- inst->buffers.output_meta.extra_count = 0;
- inst->buffers.output_meta.actual_count = 0;
- inst->buffers.output_meta.size = 0;
- f = &inst->fmts[INPUT_PORT];
- f->type = INPUT_MPLANE;
- f->fmt.pix_mp.pixelformat = V4L2_PIX_FMT_VIDC_NV12C;
- f->fmt.pix_mp.width = DEFAULT_WIDTH;
- f->fmt.pix_mp.height = DEFAULT_HEIGHT;
- f->fmt.pix_mp.num_planes = 1;
- colorformat = v4l2_colorformat_to_driver(f->fmt.pix_mp.pixelformat,
- __func__);
- f->fmt.pix_mp.plane_fmt[0].bytesperline =
- video_y_stride_bytes(colorformat, DEFAULT_WIDTH);
- f->fmt.pix_mp.plane_fmt[0].sizeimage = call_session_op(core,
- buffer_size, inst, MSM_VIDC_BUF_INPUT);
- f->fmt.pix_mp.field = V4L2_FIELD_NONE;
- f->fmt.pix_mp.colorspace = V4L2_COLORSPACE_DEFAULT;
- f->fmt.pix_mp.xfer_func = V4L2_XFER_FUNC_DEFAULT;
- f->fmt.pix_mp.ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT;
- f->fmt.pix_mp.quantization = V4L2_QUANTIZATION_DEFAULT;
- inst->buffers.input.min_count = call_session_op(core,
- min_count, inst, MSM_VIDC_BUF_INPUT);
- inst->buffers.input.extra_count = call_session_op(core,
- extra_count, inst, MSM_VIDC_BUF_INPUT);
- inst->buffers.input.actual_count =
- inst->buffers.input.min_count +
- inst->buffers.input.extra_count;
- inst->buffers.input.size = f->fmt.pix_mp.plane_fmt[0].sizeimage;
- f = &inst->fmts[INPUT_META_PORT];
- f->type = INPUT_META_PLANE;
- f->fmt.meta.dataformat = V4L2_META_FMT_VIDC;
- f->fmt.meta.buffersize = MSM_VIDC_METADATA_SIZE;
- inst->buffers.input_meta.min_count = 0;
- inst->buffers.input_meta.extra_count = 0;
- inst->buffers.input_meta.actual_count = 0;
- inst->buffers.input_meta.size = 0;
- inst->hfi_rc_type = HFI_RC_VBR_CFR;
- inst->hfi_layer_type = HFI_HIER_P_SLIDING_WINDOW;
- rc = msm_venc_codec_change(inst,
- inst->fmts[OUTPUT_PORT].fmt.pix_mp.pixelformat);
- if (rc)
- return rc;
- return rc;
- }
- int msm_venc_inst_deinit(struct msm_vidc_inst *inst)
- {
- int rc = 0;
- if (!inst) {
- d_vpr_e("%s: invalid params\n", __func__);
- return -EINVAL;
- }
- rc = msm_vidc_ctrl_deinit(inst);
- if (rc)
- return rc;
- return rc;
- }
|