Linux-Rockchip Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Andy Yan" <andyshrk@163.com>
To: "Piotr Zalewski" <pZ010001011111@proton.me>
Cc: hjc@rock-chips.com, heiko@sntech.de, andy.yan@rock-chips.com,
	 maarten.lankhorst@linux.intel.com, mripard@kernel.org,
	 tzimmermann@suse.de, airlied@gmail.com, simona@ffwll.ch,
	 dri-devel@lists.freedesktop.org,
	 linux-arm-kernel@lists.infradead.org,
	 linux-rockchip@lists.infradead.org,
	linux-kernel@vger.kernel.org,  skhan@linuxfoundation.org,
	"Daniel Stone" <daniel@fooishbar.org>,
	 "Dragan Simic" <dsimic@manjaro.org>,
	 "Diederik de Haas" <didi.debian@cknow.org>
Subject: Re:Re:Re:[PATCH v5] rockchip/drm: vop2: add support for gamma LUT
Date: Wed, 16 Oct 2024 09:10:30 +0800 (CST)	[thread overview]
Message-ID: <1ae9f15d.e52.19292e05e73.Coremail.andyshrk@163.com> (raw)
In-Reply-To: <1974DYrs9gLrQrZ5VwCglFgKDDK686iyqnS_g6uPB-s9wZ_4CqfZXPjmYWihLgrkRu7ptNjpkFeqB0uTt73RFId6cL8FowQ8LFltPmaKCoI=@proton.me>


Hi Piotr,

At 2024-10-16 04:13:40, "Piotr Zalewski" <pZ010001011111@proton.me> wrote:
>Hi Andy
>
>On Tuesday, October 15th, 2024 at 2:22 PM, Andy Yan <andyshrk@163.com> wrote:
>
>> > > > + struct vop2_video_port *vp,
>> > > > + struct drm_crtc *crtc,
>> > > > + struct drm_crtc_state *crtc_state)
>> > > > +{
>> > > > +
>> > > > + if (vop2->lut_regs && crtc_state->color_mgmt_changed) {
>> > > > + if (!crtc_state->gamma_lut) {
>> > > > + vop2_vp_dsp_lut_disable(vp);
>> > > > + return;
>> > > > + }
>> > > > +
>> > > > + if (vop2_supports_seamless_gamma_lut_update(vop2)) {
>> > > 
>> > > I think it's bettery to check for rk3568/rk3566 here, the newer soc will all follow
>> > > rk3588 support seamless gamma lut update.
>> > 
>> > I will change in the next version.
>> > 
>> > > > + vop2_writel(vop2, RK3568_LUT_PORT_SEL, FIELD_PREP(
>> > > > + RK3588_LUT_PORT_SEL__GAMMA_AHB_WRITE_SEL,
>> > > > + vp->id));
>> > > > + vop2_crtc_write_gamma_lut(vop2, crtc);
>> > > > + vop2_vp_dsp_lut_enable(vp);
>> > > > + vop2_vp_dsp_lut_update_enable(vp);
>> > > > + } else {
>> > > 
>> > > As for rk3566/68, we should do exclusive check here, because there is only
>> > > one gamma , only one VP can use it at a time. See my comments in V3:
>> > 
>> > What do you mean exactly by exclusive check in this case.It's true that
>> > gamma LUT is shared across video ports in rk356x but, if I correctly
>> > understand, this doesn't forbid to reprogram LUT port sel and allow other
>> > VP to use gamma LUT.
>> 
>> 
>> Yes, we can reprogram LUT port sel, but we need to make sure the the dsp_lut_en bit in VPx is cleared if we
>> want reprogram LUT port sel form VPx to VPy.
>> 
>
>Ok I get it now. Is such rework correct? - when gamma LUT for rk356x is
>being set, instead of disabling the LUT before the gamma LUT write for the
>current CRTC's video port, active video port is selected. Selection is 
>based on if DSP LUT EN bit is set for particular video port. eg:

If the userspace want to set gamma for CRTCx,  then that is indeed where they want to set the
gamma on。The driver silently sets the gamma on another CRTC, which is not what the user wants.

I think there are two options:
(1)return a error if gamma is enable on other CRTC, this is what we done in our BSP code[1]
  (2)  disable the dsp_lut on privious CRTC, then switch to the current CRTC which userspace wants.

[1]https://github.com/armbian/linux-rockchip/blob/rk3576-6.1-dev-2024_04_19/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c#L3666


>```
>static struct vop2_video_port *vop2_vp_dsp_lut_get_active_vp(struct vop2 *vop2)
>{
>	struct vop2_video_port *vp;
>	int i;
>	for (i = 0; i < vop2->data->nr_vps; i++) {
>		vp = &vop2->vps[i];
>
>		if (vp->crtc.dev != NULL && vop2_vp_dsp_lut_is_enabled(vp)) {
>			return vp;
>		}
>	}
>	return NULL;
>}
>
>(...)
>
>struct vop2_video_port *active_vp = vop2_vp_dsp_lut_get_active_vp(vop2);
>
>if (active_vp) {
>	vop2_vp_dsp_lut_disable(active_vp);
>	vop2_cfg_done(active_vp);
>	if (!vop2_vp_dsp_lut_poll_disable(active_vp))
>		return;
>}
>
>vop2_writel(vop2, RK3568_LUT_PORT_SEL, vp->id);
>vop2_crtc_write_gamma_lut(vop2, crtc);
>vop2_vp_dsp_lut_enable(vp);
>```
>
>
>> > > > 
>> > > > drm_crtc_helper_add(&vp->crtc, &vop2_crtc_helper_funcs);
>> > > > + if (vop2->lut_regs && vp->crtc.dev != NULL) {
>> > > > + const struct vop2_video_port_data *vp_data = &vop2_data->vp[vp->id];
>> > > > 
>> > > > + drm_mode_crtc_set_gamma_size(&vp->crtc, vp_data->gamma_lut_len);
>> > > > + drm_crtc_enable_color_mgmt(&vp->crtc, 0, false,
>> > > > + vp_data->gamma_lut_len);
>> > > 
>> > > It seems that we can keep it in one line, the default limit of linux kernel coding style is 100 characters now.
>> > 
>> > Thanks. I didn't know, I will amend it.
>> 
>> 
>> See bdc48fa11e46("checkpatch/coding-style: deprecate 80-column warning")
>> 
>
>Interesting.
>
>Best regards, Piotr Zalewski
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

  reply	other threads:[~2024-10-16  1:14 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-14 22:30 [PATCH v5] rockchip/drm: vop2: add support for gamma LUT Piotr Zalewski
2024-10-15  3:38 ` Andy Yan
2024-10-15 11:55   ` Piotr Zalewski
2024-10-15 12:22     ` Andy Yan
2024-10-15 20:13       ` Piotr Zalewski
2024-10-16  1:10         ` Andy Yan [this message]
2024-10-16  7:41           ` Piotr Zalewski
2024-10-16  7:43             ` Piotr Zalewski
2024-10-16  9:16           ` Piotr Zalewski
2024-10-16  9:20             ` [PATCH " Diederik de Haas
2024-10-16  9:24               ` Piotr Zalewski
2024-10-16 12:27           ` Daniel Stone
2024-10-16 19:19             ` Piotr Zalewski
2024-10-16 20:17               ` Daniel Stone
2024-10-16  1:26 ` Andy Yan
2024-10-16  9:23   ` Piotr Zalewski
2024-10-16 22:04     ` Piotr Zalewski

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=1ae9f15d.e52.19292e05e73.Coremail.andyshrk@163.com \
    --to=andyshrk@163.com \
    --cc=airlied@gmail.com \
    --cc=andy.yan@rock-chips.com \
    --cc=daniel@fooishbar.org \
    --cc=didi.debian@cknow.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=dsimic@manjaro.org \
    --cc=heiko@sntech.de \
    --cc=hjc@rock-chips.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=pZ010001011111@proton.me \
    --cc=simona@ffwll.ch \
    --cc=skhan@linuxfoundation.org \
    --cc=tzimmermann@suse.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox