Skip to content

Commit

Permalink
media: qcom: venus: add msm8953 hacks
Browse files Browse the repository at this point in the history
on msm8953 venus is not happy with out_height not being aligned to 32
and emits change event.
The problem is that current code treat width/height from event data as
input width/height, which might (not) be true for older firmware.
But if it was input width/height we wouldn't need to change because
we already align input height. So it could be output or both
input/output dimensions.

Also we can (and should) skip reconfiguration and continue session if we
have sufficient resources.
  • Loading branch information
vldly committed Jun 13, 2022
1 parent 466c063 commit c19a716
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
33 changes: 21 additions & 12 deletions drivers/media/platform/qcom/venus/vdec.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,7 @@ vdec_try_fmt_common(struct venus_inst *inst, struct v4l2_format *f)
pixmp->height = clamp(pixmp->height, frame_height_min(inst),
frame_height_max(inst));

if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
pixmp->height = ALIGN(pixmp->height, 32);
pixmp->height = ALIGN(pixmp->height, 32);

if (pixmp->field == V4L2_FIELD_ANY)
pixmp->field = V4L2_FIELD_NONE;
Expand Down Expand Up @@ -307,7 +306,7 @@ static int vdec_s_fmt(struct file *file, void *fh, struct v4l2_format *f)

if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
inst->out_width = format.fmt.pix_mp.width;
inst->out_height = format.fmt.pix_mp.height;
inst->out_height = ALIGN(format.fmt.pix_mp.height, 32);
inst->colorspace = pixmp->colorspace;
inst->ycbcr_enc = pixmp->ycbcr_enc;
inst->quantization = pixmp->quantization;
Expand All @@ -324,7 +323,7 @@ static int vdec_s_fmt(struct file *file, void *fh, struct v4l2_format *f)
vdec_try_fmt_common(inst, &format);

inst->width = format.fmt.pix_mp.width;
inst->height = format.fmt.pix_mp.height;
inst->height = ALIGN(format.fmt.pix_mp.height, 32);
inst->crop.top = 0;
inst->crop.left = 0;
inst->crop.width = inst->width;
Expand Down Expand Up @@ -1396,6 +1395,7 @@ static void vdec_event_change(struct venus_inst *inst,
.u.src_change.changes = V4L2_EVENT_SRC_CH_RESOLUTION };
struct device *dev = inst->core->dev_dec;
struct v4l2_format format = {};
bool changed = false;

mutex_lock(&inst->lock);

Expand All @@ -1406,8 +1406,12 @@ static void vdec_event_change(struct venus_inst *inst,

vdec_try_fmt_common(inst, &format);

inst->width = format.fmt.pix_mp.width;
inst->height = format.fmt.pix_mp.height;
if (inst->width != format.fmt.pix_mp.width ||
inst->height != format.fmt.pix_mp.height ||
inst->out_width != ev_data->width ||
inst->out_height != ev_data->height)
changed = true;

/*
* Some versions of the firmware do not report crop information for
* all codecs. For these cases, set the crop to the coded resolution.
Expand Down Expand Up @@ -1447,7 +1451,10 @@ static void vdec_event_change(struct venus_inst *inst,
break;
case VENUS_DEC_STATE_DECODING:
case VENUS_DEC_STATE_DRAIN:
inst->codec_state = VENUS_DEC_STATE_DRC;
if (sufficient)
hfi_session_continue(inst);
else
inst->codec_state = VENUS_DEC_STATE_DRC;
break;
default:
break;
Expand All @@ -1469,10 +1476,12 @@ static void vdec_event_change(struct venus_inst *inst,
dev_dbg(dev, VDBGH "flush output error %d\n", ret);
}

inst->next_buf_last = true;
inst->reconfig = true;
v4l2_event_queue_fh(&inst->fh, &ev);
wake_up(&inst->reconf_wait);
if (changed) {
inst->next_buf_last = true;
inst->reconfig = true;
v4l2_event_queue_fh(&inst->fh, &ev);
wake_up(&inst->reconf_wait);
}

mutex_unlock(&inst->lock);
}
Expand Down Expand Up @@ -1535,7 +1544,7 @@ static void vdec_inst_init(struct venus_inst *inst)
inst->crop.height = inst->height;
inst->fw_min_cnt = 8;
inst->out_width = frame_width_min(inst);
inst->out_height = frame_height_min(inst);
inst->out_height = ALIGN(frame_height_min(inst), 32);
inst->fps = 30;
inst->timeperframe.numerator = 1;
inst->timeperframe.denominator = 30;
Expand Down
5 changes: 3 additions & 2 deletions drivers/media/platform/qcom/venus/venc.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,10 @@ venc_try_fmt_common(struct venus_inst *inst, struct v4l2_format *f)

if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
pixmp->width = ALIGN(pixmp->width, 128);
pixmp->height = ALIGN(pixmp->height, 32);
}

pixmp->height = ALIGN(pixmp->height, 32);

pixmp->width = ALIGN(pixmp->width, 2);
pixmp->height = ALIGN(pixmp->height, 2);

Expand Down Expand Up @@ -1316,7 +1317,7 @@ static void venc_inst_init(struct venus_inst *inst)
inst->width = 1280;
inst->height = ALIGN(720, 32);
inst->out_width = 1280;
inst->out_height = 720;
inst->out_height = ALIGN(720, 32);
inst->fps = 15;
inst->timeperframe.numerator = 1;
inst->timeperframe.denominator = 15;
Expand Down

0 comments on commit c19a716

Please sign in to comment.