All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans Verkuil <hansverk@cisco.com>
To: Stanimir Varbanov <stanimir.varbanov@linaro.org>,
	Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Andy Gross <andy.gross@linaro.org>,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	Stephen Boyd <sboyd@codeaurora.org>,
	Srinivas Kandagatla <srinivas.kandagatla@linaro.org>,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-msm@vger.kernel.org
Subject: Re: [PATCH 3/8] media: vidc: decoder: add video decoder files
Date: Tue, 23 Aug 2016 15:12:38 +0200	[thread overview]
Message-ID: <57BC4BC6.5000102@cisco.com> (raw)
In-Reply-To: <8d32132a-e831-edb6-e2ae-e3b24677da96@linaro.org>

On 08/23/16 14:45, Stanimir Varbanov wrote:
> Hi Hans,
> 
> Thanks for the valuable comments!
> 
> <cut>
> 
>>> +static int vdec_s_parm(struct file *file, void *fh, struct v4l2_streamparm *a)
>>> +{
>>> +	struct vidc_inst *inst = to_inst(file);
>>> +	struct v4l2_captureparm *cap = &a->parm.capture;
>>> +	struct v4l2_fract *timeperframe = &cap->timeperframe;
>>> +	u64 us_per_frame, fps;
>>> +
>>> +	if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE &&
>>> +	    a->type != V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
>>> +		return -EINVAL;
>>> +
>>> +	memset(cap->reserved, 0, sizeof(cap->reserved));
>>> +	if (!timeperframe->denominator)
>>> +		timeperframe->denominator = inst->timeperframe.denominator;
>>> +	if (!timeperframe->numerator)
>>> +		timeperframe->numerator = inst->timeperframe.numerator;
>>> +	cap->readbuffers = 0;
>>
>> Just set readbuffers to the minimum number of required buffers. Hmm, shouldn't
>> v4l2-compliance complain about a 0 value for readbuffers? Odd.
> 
> I guess I misunderstood the meaning of those fields and just zeroing
> them to make v4l2-compliance happy.

These fields are really left-overs from old times. One of these days I'll
probably remove them. I think that there are still one or two old drivers
that actually use these.

>>> +static int vdec_start_streaming(struct vb2_queue *q, unsigned int count)
>>> +{
>>> +	struct vidc_inst *inst = vb2_get_drv_priv(q);
>>> +	struct hfi_core *hfi = &inst->core->hfi;
>>> +	struct device *dev = inst->core->dev;
>>> +	struct hfi_buffer_requirements bufreq;
>>> +	struct hfi_buffer_count_actual buf_count;
>>> +	struct vb2_queue *queue;
>>> +	u32 ptype;
>>> +	int ret;
>>> +
>>> +	switch (q->type) {
>>> +	case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
>>> +		queue = &inst->bufq_cap;
>>> +		break;
>>> +	case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
>>> +		queue = &inst->bufq_out;
>>> +		break;
>>> +	default:
>>
>> If start_streaming fails, then all pending buffers have to be returned by the driver
>> by calling vb2_buffer_done(VB2_BUF_STATE_QUEUED). This will give ownership back to
>> userspace.
> 
> Infact this error path shouldn't be possible, because videobu2-core
> should check q->type before jumping here?

Sorry, I wasn't clear. It is not just this place (and you are right, the error
path here isn't possible), but any place where an error is returned in this
function.

Those should be replaced by a goto fail; and in the fail label all pending buffers
have to be returned. Same code as in stop_streaming, but you call vb2_buffer_done
with state QUEUED instead of state ERROR.

> 
>>
>>> +		return -EINVAL;
>>> +	}
>>> +
>>> +	if (!vb2_is_streaming(queue))
>>> +		return 0;
>>
>> Can never happen, no need to test for this.
> 
> This can happen cause start_streaming is called for OUTPUT and for
> CAPTURE queues, see the above switch (q->type). If start_streaming is
> called for the CAPTURE thus vb2_is_streaming() checks does
> start_streaming is already called for OUTPUT. So this guarantee that the
> firmware will be started when the streaming is started for both queues.

Ah, now I see it. Please rename 'queue' to 'other_queue' or something like
that. I thought it was the queue that start_streaming was called for, but
that is called 'q'. A bit confusing :-)

> 
>>
>>> +
>>> +	inst->in_reconfig = false;
>>> +	inst->sequence = 0;
>>> +
>>> +	ret = pm_runtime_get_sync(dev);
>>> +	if (ret < 0)
>>> +		return ret;
>>> +
>>> +	ret = vdec_init_session(inst);
>>> +	if (ret)
>>> +		goto put_sync;
>>> +
>>> +	ret = vdec_set_properties(inst);
>>> +	if (ret)
>>> +		goto deinit_sess;
>>> +
>>> +	ret = vdec_check_configuration(inst);
>>> +	if (ret)
>>> +		goto deinit_sess;
>>> +
>>> +	ptype = HFI_PROPERTY_PARAM_BUFFER_COUNT_ACTUAL;
>>> +	buf_count.type = HFI_BUFFER_INPUT;
>>> +	buf_count.count_actual = inst->num_input_bufs;
>>> +
>>> +	ret = vidc_hfi_session_set_property(hfi, inst->hfi_inst,
>>> +					    ptype, &buf_count);
>>> +	if (ret)
>>> +		goto deinit_sess;
>>> +
>>> +	ret = vidc_buf_descs(inst, HFI_BUFFER_OUTPUT, &bufreq);
>>> +	if (ret)
>>> +		goto deinit_sess;
>>> +
>>> +	ptype = HFI_PROPERTY_PARAM_BUFFER_COUNT_ACTUAL;
>>> +	buf_count.type = HFI_BUFFER_OUTPUT;
>>> +	buf_count.count_actual = inst->num_output_bufs;
>>> +
>>> +	ret = vidc_hfi_session_set_property(hfi, inst->hfi_inst,
>>> +					    ptype, &buf_count);
>>> +	if (ret)
>>> +		goto deinit_sess;
>>> +
>>> +	if (inst->num_output_bufs != bufreq.count_actual) {
>>> +		struct hfi_buffer_display_hold_count_actual display;
>>> +
>>> +		ptype = HFI_PROPERTY_PARAM_BUFFER_DISPLAY_HOLD_COUNT_ACTUAL;
>>> +		display.type = HFI_BUFFER_OUTPUT;
>>> +		display.hold_count = inst->num_output_bufs -
>>> +				     bufreq.count_actual;
>>> +
>>> +		ret = vidc_hfi_session_set_property(hfi, inst->hfi_inst,
>>> +						    ptype, &display);
>>> +		if (ret)
>>> +			goto deinit_sess;
>>> +	}
>>> +
>>> +	ret = vidc_vb2_start_streaming(inst);
>>> +	if (ret)
>>> +		goto deinit_sess;
>>> +
>>> +	return 0;
>>> +
>>> +deinit_sess:
>>> +	vidc_hfi_session_deinit(hfi, inst->hfi_inst);
>>
>> Note that vidc_vb2_start_streaming already calls vidc_hfi_session_deinit on error.
> 
> Probably you wanted to say vdec_init_session has deinit on error path?
> If so I cannot see the problem, vidc_hfi_session_deinit is called only once?

Never mind. I thought vidc_hfi_session_deinit() was called from vidc_vb2_start_streaming,
but it is called from vidc_vb2_stop_streaming. My mistake.

>>> +static int vdec_op_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
>>> +{
>>> +	struct vidc_inst *inst = ctrl_to_inst(ctrl);
>>> +	struct vdec_controls *ctr = &inst->controls.dec;
>>> +	struct hfi_core *hfi = &inst->core->hfi;
>>> +	union hfi_get_property hprop;
>>> +	u32 ptype = HFI_PROPERTY_PARAM_PROFILE_LEVEL_CURRENT;
>>> +	int ret;
>>> +
>>> +	switch (ctrl->id) {
>>> +	case V4L2_CID_MPEG_VIDEO_H264_PROFILE:
>>> +	case V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE:
>>> +	case V4L2_CID_MPEG_VIDEO_VPX_PROFILE:
>>> +		ret = vidc_hfi_session_get_property(hfi, inst->hfi_inst, ptype,
>>> +						    &hprop);
>>> +		if (!ret)
>>> +			ctr->profile = hprop.profile_level.profile;
>>> +		ctrl->val = ctr->profile;
>>> +		break;
>>> +	case V4L2_CID_MPEG_VIDEO_H264_LEVEL:
>>> +	case V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL:
>>> +		ret = vidc_hfi_session_get_property(hfi, inst->hfi_inst, ptype,
>>> +						    &hprop);
>>> +		if (!ret)
>>> +			ctr->level = hprop.profile_level.level;
>>> +		ctrl->val = ctr->level;
>>> +		break;
>>> +	case V4L2_CID_MPEG_VIDEO_DECODER_MPEG4_DEBLOCK_FILTER:
>>> +		ctrl->val = ctr->post_loop_deb_mode;
>>> +		break;
>>
>> Why are these volatile?
> 
> Because the firmware acording to stream headers that profile and levels
> are different.

But when these change, isn't the driver told about it? And can these
change midstream? I would expect this to be set once when you start
decoding and not change afterwards.

Regards,

	Hans

  reply	other threads:[~2016-08-23 13:12 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-22 13:13 [PATCH 0/8] Qualcomm video decoder/encoder driver Stanimir Varbanov
     [not found] ` <1471871619-25873-1-git-send-email-stanimir.varbanov-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2016-08-22 13:13   ` [PATCH 1/8] doc: DT: vidc: binding document for Qualcomm video driver Stanimir Varbanov
2016-08-22 13:13     ` Stanimir Varbanov
2016-08-22 13:13 ` [PATCH 2/8] media: vidc: adding core part and helper functions Stanimir Varbanov
2016-08-22 13:41   ` Hans Verkuil
2016-08-22 16:03     ` Stanimir Varbanov
2016-08-23  2:50   ` Bjorn Andersson
2016-08-25 12:59     ` Stanimir Varbanov
2016-08-25 18:26       ` Bjorn Andersson
2016-08-22 13:13 ` [PATCH 3/8] media: vidc: decoder: add video decoder files Stanimir Varbanov
2016-08-22 14:38   ` Hans Verkuil
2016-08-23 12:45     ` Stanimir Varbanov
2016-08-23 13:12       ` Hans Verkuil [this message]
2016-08-29 14:22         ` Stanimir Varbanov
2016-08-22 13:13 ` [PATCH 4/8] media: vidc: encoder: add video encoder files Stanimir Varbanov
2016-08-22 13:13 ` [PATCH 5/8] media: vidc: add Host Firmware Interface (HFI) Stanimir Varbanov
2016-08-23  3:25   ` Bjorn Andersson
2016-08-26 14:21     ` Stanimir Varbanov
2016-08-22 13:13 ` [PATCH 6/8] media: vidc: add Venus HFI files Stanimir Varbanov
2016-08-23  3:35   ` Bjorn Andersson
2016-08-22 13:13 ` [PATCH 7/8] media: vidc: add Makefiles and Kconfig files Stanimir Varbanov
2016-08-22 13:13 ` [PATCH 8/8] media: vidc: enable building of the video codec driver Stanimir Varbanov
2016-09-05 14:47 ` [PATCH 0/8] Qualcomm video decoder/encoder driver Hans Verkuil
2016-09-07  8:57   ` Stanimir Varbanov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=57BC4BC6.5000102@cisco.com \
    --to=hansverk@cisco.com \
    --cc=andy.gross@linaro.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=sboyd@codeaurora.org \
    --cc=srinivas.kandagatla@linaro.org \
    --cc=stanimir.varbanov@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.