All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Osipenko <dmitry.osipenko@collabora.com>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org,
	Benjamin Gaignard <benjamin.gaignard@collabora.com>,
	Peter Geis <pgwipeout@gmail.com>,
	Sandy Huang <hjc@rock-chips.com>,
	linux-rockchip@lists.infradead.org,
	Michael Riesch <michael.riesch@wolfvision.net>,
	kernel@pengutronix.de, Andy Yan <andy.yan@rock-chips.com>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v5 22/23] drm: rockchip: Add VOP2 driver
Date: Wed, 16 Feb 2022 15:23:32 +0300	[thread overview]
Message-ID: <e560b6b3-c0e7-8e23-2490-154a2508c801@collabora.com> (raw)
In-Reply-To: <20220216112250.GN18637@pengutronix.de>



16.02.2022 14:22, Sascha Hauer пишет:
> On Wed, Feb 16, 2022 at 01:39:33PM +0300, Dmitry Osipenko wrote:
>> 09.02.2022 12:53, Sascha Hauer пишет:
>>> +static void vop2_plane_atomic_update(struct drm_plane *plane, struct drm_atomic_state *state)
>>> +{
>>> +	struct drm_plane_state *pstate = plane->state;
>>> +	struct drm_crtc *crtc = pstate->crtc;
>>> +	struct vop2_win *win = to_vop2_win(plane);
>>> +	struct vop2_video_port *vp = to_vop2_video_port(crtc);
>>> +	struct drm_display_mode *adjusted_mode = &crtc->state->adjusted_mode;
>>> +	struct vop2 *vop2 = win->vop2;
>>> +	struct drm_framebuffer *fb = pstate->fb;
>>> +	uint32_t bpp = fb->format->cpp[0] * 8;
>>> +	uint32_t actual_w, actual_h, dsp_w, dsp_h;
>>> +	uint32_t act_info, dsp_info;
>>> +	uint32_t format;
>>> +	uint32_t afbc_format;
>>> +	uint32_t rb_swap;
>>> +	uint32_t uv_swap;
>>> +	struct drm_rect *src = &pstate->src;
>>> +	struct drm_rect *dest = &pstate->dst;
>>> +	uint32_t afbc_tile_num;
>>> +	uint32_t transform_offset;
>>> +	bool dither_up;
>>> +	bool xmirror = pstate->rotation & DRM_MODE_REFLECT_X;
>>> +	bool ymirror = pstate->rotation & DRM_MODE_REFLECT_Y;
>>> +	bool rotate_270 = pstate->rotation & DRM_MODE_ROTATE_270;
>>> +	bool rotate_90 = pstate->rotation & DRM_MODE_ROTATE_90;
>>> +	struct rockchip_gem_object *rk_obj;
>>> +	unsigned long offset;
>>> +	bool afbc_en;
>>> +	dma_addr_t yrgb_mst;
>>> +	dma_addr_t uv_mst;
>>> +
>>> +	/*
>>> +	 * can't update plane when vop2 is disabled.
>>> +	 */
>>> +	if (WARN_ON(!crtc))
>>> +		return;
>>> +
>>> +	if (!pstate->visible) {
>>> +		vop2_plane_atomic_disable(plane, state);
>>> +		return;
>>> +	}
>>> +
>>> +	afbc_en = rockchip_afbc(plane, fb->modifier);
>>> +
>>> +	offset = (src->x1 >> 16) * fb->format->cpp[0];
>>> +
>>> +	/*
>>> +	 * AFBC HDR_PTR must set to the zero offset of the framebuffer.
>>> +	 */
>>> +	if (afbc_en)
>>> +		offset = 0;
>>> +	else if (pstate->rotation & DRM_MODE_REFLECT_Y)
>>> +		offset += ((src->y2 >> 16) - 1) * fb->pitches[0];
>>> +	else
>>> +		offset += (src->y1 >> 16) * fb->pitches[0];
>>> +
>>> +	rk_obj = to_rockchip_obj(fb->obj[0]);
>>> +
>>> +	yrgb_mst = rk_obj->dma_addr + offset + fb->offsets[0];
>>> +	if (fb->format->is_yuv) {
>>> +		int hsub = fb->format->hsub;
>>> +		int vsub = fb->format->vsub;
>>> +
>>> +		offset = (src->x1 >> 16) * fb->format->cpp[1] / hsub;
>>> +		offset += (src->y1 >> 16) * fb->pitches[1] / vsub;
>>> +
>>> +		if ((pstate->rotation & DRM_MODE_REFLECT_Y) && !afbc_en)
>>> +			offset += fb->pitches[1] * ((pstate->src_h >> 16) - 2)  / vsub;
>>> +
>>> +		rk_obj = to_rockchip_obj(fb->obj[0]);
>>> +		uv_mst = rk_obj->dma_addr + offset + fb->offsets[1];
>>> +	}
>>> +
>>> +	actual_w = drm_rect_width(src) >> 16;
>>> +	actual_h = drm_rect_height(src) >> 16;
>>> +	dsp_w = drm_rect_width(dest);
>>> +
>>> +	if (dest->x1 + dsp_w > adjusted_mode->hdisplay) {
>>> +		drm_err(vop2->drm, "vp%d %s dest->x1[%d] + dsp_w[%d] exceed mode hdisplay[%d]\n",
>>> +			  vp->id, win->data->name, dest->x1, dsp_w, adjusted_mode->hdisplay);
>>> +		dsp_w = adjusted_mode->hdisplay - dest->x1;
>>> +		if (dsp_w < 4)
>>> +			dsp_w = 4;
>>> +		actual_w = dsp_w * actual_w / drm_rect_width(dest);
>>> +	}
>>> +
>>> +	dsp_h = drm_rect_height(dest);
>>> +
>>> +	if (dest->y1 + dsp_h > adjusted_mode->vdisplay) {
>>> +		drm_err(vop2->drm, "vp%d %s dest->y1[%d] + dsp_h[%d] exceed mode vdisplay[%d]\n",
>>> +			  vp->id, win->data->name, dest->y1, dsp_h, adjusted_mode->vdisplay);
>>> +		dsp_h = adjusted_mode->vdisplay - dest->y1;
>>> +		if (dsp_h < 4)
>>> +			dsp_h = 4;
>>> +		actual_h = dsp_h * actual_h / drm_rect_height(dest);
>>> +	}
>>> +
>>> +	/*
>>> +	 * This is workaround solution for IC design:
>>> +	 * esmart can't support scale down when actual_w % 16 == 1.
>>> +	 */
>>> +	if (!(win->data->feature & WIN_FEATURE_AFBDC)) {
>>> +		if (actual_w > dsp_w && (actual_w & 0xf) == 1) {
>>> +			drm_err(vop2->drm, "vp%d %s act_w[%d] MODE 16 == 1\n", vp->id, win->data->name, actual_w);
>>> +			actual_w -= 1;
>>> +		}
>>> +	}
>>> +
>>> +	if (afbc_en && actual_w % 4) {
>>> +		drm_err(vop2->drm, "vp%d %s actual_w[%d] should align as 4 pixel when enable afbc\n",
>>> +			  vp->id, win->data->name, actual_w);
>>> +		actual_w = ALIGN_DOWN(actual_w, 4);
>>> +	}
>>> +
>>> +	act_info = (actual_h - 1) << 16 | ((actual_w - 1) & 0xffff);
>>> +	dsp_info = (dsp_h - 1) << 16 | ((dsp_w - 1) & 0xffff);
>>> +
>>> +	format = vop2_convert_format(fb->format->format);
>>> +
>>> +	drm_dbg(vop2->drm, "vp%d update %s[%dx%d->%dx%d@%dx%d] fmt[%p4cc_%s] addr[%pad]\n",
>>> +		      vp->id, win->data->name, actual_w, actual_h, dsp_w, dsp_h,
>>> +		      dest->x1, dest->y1,
>>> +		      &fb->format->format,
>>> +		      afbc_en ? "AFBC" : "", &yrgb_mst);
>>> +
>>> +	if (afbc_en) {
>>> +		uint32_t stride;
>>> +
>>> +		/* the afbc superblock is 16 x 16 */
>>> +		afbc_format = vop2_convert_afbc_format(fb->format->format);
>>> +
>>> +		/* Enable color transform for YTR */
>>> +		if (fb->modifier & AFBC_FORMAT_MOD_YTR)
>>> +			afbc_format |= (1 << 4);
>>> +
>>> +		afbc_tile_num = ALIGN(actual_w, 16) >> 4;
>>> +
>>> +		/*
>>> +		 * AFBC pic_vir_width is count by pixel, this is different
>>> +		 * with WIN_VIR_STRIDE.
>>> +		 */
>>> +		stride = (fb->pitches[0] << 3) / bpp;
>>> +		if ((stride & 0x3f) && (xmirror || rotate_90 || rotate_270))
>>> +			drm_err(vop2->drm, "vp%d %s stride[%d] must align as 64 pixel when enable xmirror/rotate_90/rotate_270[0x%x]\n",
>>> +				  vp->id, win->data->name, stride, pstate->rotation);
>>> +
>>> +		rb_swap = vop2_afbc_rb_swap(fb->format->format);
>>> +		uv_swap = vop2_afbc_uv_swap(fb->format->format);
>>> +		/*
>>> +		 * This is a workaround for crazy IC design, Cluster
>>> +		 * and Esmart/Smart use different format configuration map:
>>> +		 * YUV420_10BIT: 0x10 for Cluster, 0x14 for Esmart/Smart.
>>> +		 *
>>> +		 * This is one thing we can make the convert simple:
>>> +		 * AFBCD decode all the YUV data to YUV444. So we just
>>> +		 * set all the yuv 10 bit to YUV444_10.
>>> +		 */
>>> +		if (fb->format->is_yuv && (bpp == 10))
>>> +			format = VOP2_CLUSTER_YUV444_10;
>>> +
>>> +		if (vop2_cluster_window(win))
>>> +			vop2_win_write(win, VOP2_WIN_AFBC_ENABLE, 1);
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_FORMAT, afbc_format);
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_RB_SWAP, rb_swap);
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_UV_SWAP, uv_swap);
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_AUTO_GATING_EN, 0);
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_BLOCK_SPLIT_EN, 0);
>>> +		if (pstate->rotation & (DRM_MODE_ROTATE_270 | DRM_MODE_ROTATE_90)) {
>>> +			vop2_win_write(win, VOP2_WIN_AFBC_HALF_BLOCK_EN, 0);
>>> +			transform_offset = vop2_afbc_transform_offset(pstate, false);
>>> +		} else {
>>> +			vop2_win_write(win, VOP2_WIN_AFBC_HALF_BLOCK_EN, 1);
>>> +			transform_offset = vop2_afbc_transform_offset(pstate, true);
>>> +		}
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_HDR_PTR, yrgb_mst);
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_PIC_SIZE, act_info);
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_TRANSFORM_OFFSET, transform_offset);
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_PIC_OFFSET, ((src->x1 >> 16) | src->y1));
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_DSP_OFFSET, (dest->x1 | (dest->y1 << 16)));
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_PIC_VIR_WIDTH, stride);
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_TILE_NUM, afbc_tile_num);
>>> +		vop2_win_write(win, VOP2_WIN_XMIRROR, xmirror);
>>
>> The xmirror's variable type is specified as bool, but it's not
>> true/false because in the above code:
>>
>> bool xmirror = pstate->rotation & DRM_MODE_REFLECT_X;
>>
>> I don't see how vop2_win_write() could work properly. Or am I missing
>> something?
> 
> Everything != 0 is true, so 0x10 & 0x10 is still true.

Ah, my bad. I keep forgetting that kernel uses _Bool.

> But ok,
> 
> 	bool xmirror = pstate->rotation & DRM_MODE_REFLECT_X ? true : false;
> 
> looks cleaner. I'll change that.
> 
> Thanks for the review so far. Could you drop me a short note when you're
> done? I was about to send v6.

I don't have any more comments, please feel free to send v6.

WARNING: multiple messages have this Message-ID (diff)
From: Dmitry Osipenko <dmitry.osipenko@collabora.com>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org,
	Benjamin Gaignard <benjamin.gaignard@collabora.com>,
	Peter Geis <pgwipeout@gmail.com>,
	Sandy Huang <hjc@rock-chips.com>,
	linux-rockchip@lists.infradead.org,
	Michael Riesch <michael.riesch@wolfvision.net>,
	kernel@pengutronix.de, Andy Yan <andy.yan@rock-chips.com>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v5 22/23] drm: rockchip: Add VOP2 driver
Date: Wed, 16 Feb 2022 15:23:32 +0300	[thread overview]
Message-ID: <e560b6b3-c0e7-8e23-2490-154a2508c801@collabora.com> (raw)
In-Reply-To: <20220216112250.GN18637@pengutronix.de>



16.02.2022 14:22, Sascha Hauer пишет:
> On Wed, Feb 16, 2022 at 01:39:33PM +0300, Dmitry Osipenko wrote:
>> 09.02.2022 12:53, Sascha Hauer пишет:
>>> +static void vop2_plane_atomic_update(struct drm_plane *plane, struct drm_atomic_state *state)
>>> +{
>>> +	struct drm_plane_state *pstate = plane->state;
>>> +	struct drm_crtc *crtc = pstate->crtc;
>>> +	struct vop2_win *win = to_vop2_win(plane);
>>> +	struct vop2_video_port *vp = to_vop2_video_port(crtc);
>>> +	struct drm_display_mode *adjusted_mode = &crtc->state->adjusted_mode;
>>> +	struct vop2 *vop2 = win->vop2;
>>> +	struct drm_framebuffer *fb = pstate->fb;
>>> +	uint32_t bpp = fb->format->cpp[0] * 8;
>>> +	uint32_t actual_w, actual_h, dsp_w, dsp_h;
>>> +	uint32_t act_info, dsp_info;
>>> +	uint32_t format;
>>> +	uint32_t afbc_format;
>>> +	uint32_t rb_swap;
>>> +	uint32_t uv_swap;
>>> +	struct drm_rect *src = &pstate->src;
>>> +	struct drm_rect *dest = &pstate->dst;
>>> +	uint32_t afbc_tile_num;
>>> +	uint32_t transform_offset;
>>> +	bool dither_up;
>>> +	bool xmirror = pstate->rotation & DRM_MODE_REFLECT_X;
>>> +	bool ymirror = pstate->rotation & DRM_MODE_REFLECT_Y;
>>> +	bool rotate_270 = pstate->rotation & DRM_MODE_ROTATE_270;
>>> +	bool rotate_90 = pstate->rotation & DRM_MODE_ROTATE_90;
>>> +	struct rockchip_gem_object *rk_obj;
>>> +	unsigned long offset;
>>> +	bool afbc_en;
>>> +	dma_addr_t yrgb_mst;
>>> +	dma_addr_t uv_mst;
>>> +
>>> +	/*
>>> +	 * can't update plane when vop2 is disabled.
>>> +	 */
>>> +	if (WARN_ON(!crtc))
>>> +		return;
>>> +
>>> +	if (!pstate->visible) {
>>> +		vop2_plane_atomic_disable(plane, state);
>>> +		return;
>>> +	}
>>> +
>>> +	afbc_en = rockchip_afbc(plane, fb->modifier);
>>> +
>>> +	offset = (src->x1 >> 16) * fb->format->cpp[0];
>>> +
>>> +	/*
>>> +	 * AFBC HDR_PTR must set to the zero offset of the framebuffer.
>>> +	 */
>>> +	if (afbc_en)
>>> +		offset = 0;
>>> +	else if (pstate->rotation & DRM_MODE_REFLECT_Y)
>>> +		offset += ((src->y2 >> 16) - 1) * fb->pitches[0];
>>> +	else
>>> +		offset += (src->y1 >> 16) * fb->pitches[0];
>>> +
>>> +	rk_obj = to_rockchip_obj(fb->obj[0]);
>>> +
>>> +	yrgb_mst = rk_obj->dma_addr + offset + fb->offsets[0];
>>> +	if (fb->format->is_yuv) {
>>> +		int hsub = fb->format->hsub;
>>> +		int vsub = fb->format->vsub;
>>> +
>>> +		offset = (src->x1 >> 16) * fb->format->cpp[1] / hsub;
>>> +		offset += (src->y1 >> 16) * fb->pitches[1] / vsub;
>>> +
>>> +		if ((pstate->rotation & DRM_MODE_REFLECT_Y) && !afbc_en)
>>> +			offset += fb->pitches[1] * ((pstate->src_h >> 16) - 2)  / vsub;
>>> +
>>> +		rk_obj = to_rockchip_obj(fb->obj[0]);
>>> +		uv_mst = rk_obj->dma_addr + offset + fb->offsets[1];
>>> +	}
>>> +
>>> +	actual_w = drm_rect_width(src) >> 16;
>>> +	actual_h = drm_rect_height(src) >> 16;
>>> +	dsp_w = drm_rect_width(dest);
>>> +
>>> +	if (dest->x1 + dsp_w > adjusted_mode->hdisplay) {
>>> +		drm_err(vop2->drm, "vp%d %s dest->x1[%d] + dsp_w[%d] exceed mode hdisplay[%d]\n",
>>> +			  vp->id, win->data->name, dest->x1, dsp_w, adjusted_mode->hdisplay);
>>> +		dsp_w = adjusted_mode->hdisplay - dest->x1;
>>> +		if (dsp_w < 4)
>>> +			dsp_w = 4;
>>> +		actual_w = dsp_w * actual_w / drm_rect_width(dest);
>>> +	}
>>> +
>>> +	dsp_h = drm_rect_height(dest);
>>> +
>>> +	if (dest->y1 + dsp_h > adjusted_mode->vdisplay) {
>>> +		drm_err(vop2->drm, "vp%d %s dest->y1[%d] + dsp_h[%d] exceed mode vdisplay[%d]\n",
>>> +			  vp->id, win->data->name, dest->y1, dsp_h, adjusted_mode->vdisplay);
>>> +		dsp_h = adjusted_mode->vdisplay - dest->y1;
>>> +		if (dsp_h < 4)
>>> +			dsp_h = 4;
>>> +		actual_h = dsp_h * actual_h / drm_rect_height(dest);
>>> +	}
>>> +
>>> +	/*
>>> +	 * This is workaround solution for IC design:
>>> +	 * esmart can't support scale down when actual_w % 16 == 1.
>>> +	 */
>>> +	if (!(win->data->feature & WIN_FEATURE_AFBDC)) {
>>> +		if (actual_w > dsp_w && (actual_w & 0xf) == 1) {
>>> +			drm_err(vop2->drm, "vp%d %s act_w[%d] MODE 16 == 1\n", vp->id, win->data->name, actual_w);
>>> +			actual_w -= 1;
>>> +		}
>>> +	}
>>> +
>>> +	if (afbc_en && actual_w % 4) {
>>> +		drm_err(vop2->drm, "vp%d %s actual_w[%d] should align as 4 pixel when enable afbc\n",
>>> +			  vp->id, win->data->name, actual_w);
>>> +		actual_w = ALIGN_DOWN(actual_w, 4);
>>> +	}
>>> +
>>> +	act_info = (actual_h - 1) << 16 | ((actual_w - 1) & 0xffff);
>>> +	dsp_info = (dsp_h - 1) << 16 | ((dsp_w - 1) & 0xffff);
>>> +
>>> +	format = vop2_convert_format(fb->format->format);
>>> +
>>> +	drm_dbg(vop2->drm, "vp%d update %s[%dx%d->%dx%d@%dx%d] fmt[%p4cc_%s] addr[%pad]\n",
>>> +		      vp->id, win->data->name, actual_w, actual_h, dsp_w, dsp_h,
>>> +		      dest->x1, dest->y1,
>>> +		      &fb->format->format,
>>> +		      afbc_en ? "AFBC" : "", &yrgb_mst);
>>> +
>>> +	if (afbc_en) {
>>> +		uint32_t stride;
>>> +
>>> +		/* the afbc superblock is 16 x 16 */
>>> +		afbc_format = vop2_convert_afbc_format(fb->format->format);
>>> +
>>> +		/* Enable color transform for YTR */
>>> +		if (fb->modifier & AFBC_FORMAT_MOD_YTR)
>>> +			afbc_format |= (1 << 4);
>>> +
>>> +		afbc_tile_num = ALIGN(actual_w, 16) >> 4;
>>> +
>>> +		/*
>>> +		 * AFBC pic_vir_width is count by pixel, this is different
>>> +		 * with WIN_VIR_STRIDE.
>>> +		 */
>>> +		stride = (fb->pitches[0] << 3) / bpp;
>>> +		if ((stride & 0x3f) && (xmirror || rotate_90 || rotate_270))
>>> +			drm_err(vop2->drm, "vp%d %s stride[%d] must align as 64 pixel when enable xmirror/rotate_90/rotate_270[0x%x]\n",
>>> +				  vp->id, win->data->name, stride, pstate->rotation);
>>> +
>>> +		rb_swap = vop2_afbc_rb_swap(fb->format->format);
>>> +		uv_swap = vop2_afbc_uv_swap(fb->format->format);
>>> +		/*
>>> +		 * This is a workaround for crazy IC design, Cluster
>>> +		 * and Esmart/Smart use different format configuration map:
>>> +		 * YUV420_10BIT: 0x10 for Cluster, 0x14 for Esmart/Smart.
>>> +		 *
>>> +		 * This is one thing we can make the convert simple:
>>> +		 * AFBCD decode all the YUV data to YUV444. So we just
>>> +		 * set all the yuv 10 bit to YUV444_10.
>>> +		 */
>>> +		if (fb->format->is_yuv && (bpp == 10))
>>> +			format = VOP2_CLUSTER_YUV444_10;
>>> +
>>> +		if (vop2_cluster_window(win))
>>> +			vop2_win_write(win, VOP2_WIN_AFBC_ENABLE, 1);
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_FORMAT, afbc_format);
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_RB_SWAP, rb_swap);
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_UV_SWAP, uv_swap);
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_AUTO_GATING_EN, 0);
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_BLOCK_SPLIT_EN, 0);
>>> +		if (pstate->rotation & (DRM_MODE_ROTATE_270 | DRM_MODE_ROTATE_90)) {
>>> +			vop2_win_write(win, VOP2_WIN_AFBC_HALF_BLOCK_EN, 0);
>>> +			transform_offset = vop2_afbc_transform_offset(pstate, false);
>>> +		} else {
>>> +			vop2_win_write(win, VOP2_WIN_AFBC_HALF_BLOCK_EN, 1);
>>> +			transform_offset = vop2_afbc_transform_offset(pstate, true);
>>> +		}
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_HDR_PTR, yrgb_mst);
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_PIC_SIZE, act_info);
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_TRANSFORM_OFFSET, transform_offset);
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_PIC_OFFSET, ((src->x1 >> 16) | src->y1));
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_DSP_OFFSET, (dest->x1 | (dest->y1 << 16)));
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_PIC_VIR_WIDTH, stride);
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_TILE_NUM, afbc_tile_num);
>>> +		vop2_win_write(win, VOP2_WIN_XMIRROR, xmirror);
>>
>> The xmirror's variable type is specified as bool, but it's not
>> true/false because in the above code:
>>
>> bool xmirror = pstate->rotation & DRM_MODE_REFLECT_X;
>>
>> I don't see how vop2_win_write() could work properly. Or am I missing
>> something?
> 
> Everything != 0 is true, so 0x10 & 0x10 is still true.

Ah, my bad. I keep forgetting that kernel uses _Bool.

> But ok,
> 
> 	bool xmirror = pstate->rotation & DRM_MODE_REFLECT_X ? true : false;
> 
> looks cleaner. I'll change that.
> 
> Thanks for the review so far. Could you drop me a short note when you're
> done? I was about to send v6.

I don't have any more comments, please feel free to send v6.

_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

WARNING: multiple messages have this Message-ID (diff)
From: Dmitry Osipenko <dmitry.osipenko@collabora.com>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org,
	Benjamin Gaignard <benjamin.gaignard@collabora.com>,
	Peter Geis <pgwipeout@gmail.com>,
	Sandy Huang <hjc@rock-chips.com>,
	linux-rockchip@lists.infradead.org,
	Michael Riesch <michael.riesch@wolfvision.net>,
	kernel@pengutronix.de, Andy Yan <andy.yan@rock-chips.com>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v5 22/23] drm: rockchip: Add VOP2 driver
Date: Wed, 16 Feb 2022 15:23:32 +0300	[thread overview]
Message-ID: <e560b6b3-c0e7-8e23-2490-154a2508c801@collabora.com> (raw)
In-Reply-To: <20220216112250.GN18637@pengutronix.de>



16.02.2022 14:22, Sascha Hauer пишет:
> On Wed, Feb 16, 2022 at 01:39:33PM +0300, Dmitry Osipenko wrote:
>> 09.02.2022 12:53, Sascha Hauer пишет:
>>> +static void vop2_plane_atomic_update(struct drm_plane *plane, struct drm_atomic_state *state)
>>> +{
>>> +	struct drm_plane_state *pstate = plane->state;
>>> +	struct drm_crtc *crtc = pstate->crtc;
>>> +	struct vop2_win *win = to_vop2_win(plane);
>>> +	struct vop2_video_port *vp = to_vop2_video_port(crtc);
>>> +	struct drm_display_mode *adjusted_mode = &crtc->state->adjusted_mode;
>>> +	struct vop2 *vop2 = win->vop2;
>>> +	struct drm_framebuffer *fb = pstate->fb;
>>> +	uint32_t bpp = fb->format->cpp[0] * 8;
>>> +	uint32_t actual_w, actual_h, dsp_w, dsp_h;
>>> +	uint32_t act_info, dsp_info;
>>> +	uint32_t format;
>>> +	uint32_t afbc_format;
>>> +	uint32_t rb_swap;
>>> +	uint32_t uv_swap;
>>> +	struct drm_rect *src = &pstate->src;
>>> +	struct drm_rect *dest = &pstate->dst;
>>> +	uint32_t afbc_tile_num;
>>> +	uint32_t transform_offset;
>>> +	bool dither_up;
>>> +	bool xmirror = pstate->rotation & DRM_MODE_REFLECT_X;
>>> +	bool ymirror = pstate->rotation & DRM_MODE_REFLECT_Y;
>>> +	bool rotate_270 = pstate->rotation & DRM_MODE_ROTATE_270;
>>> +	bool rotate_90 = pstate->rotation & DRM_MODE_ROTATE_90;
>>> +	struct rockchip_gem_object *rk_obj;
>>> +	unsigned long offset;
>>> +	bool afbc_en;
>>> +	dma_addr_t yrgb_mst;
>>> +	dma_addr_t uv_mst;
>>> +
>>> +	/*
>>> +	 * can't update plane when vop2 is disabled.
>>> +	 */
>>> +	if (WARN_ON(!crtc))
>>> +		return;
>>> +
>>> +	if (!pstate->visible) {
>>> +		vop2_plane_atomic_disable(plane, state);
>>> +		return;
>>> +	}
>>> +
>>> +	afbc_en = rockchip_afbc(plane, fb->modifier);
>>> +
>>> +	offset = (src->x1 >> 16) * fb->format->cpp[0];
>>> +
>>> +	/*
>>> +	 * AFBC HDR_PTR must set to the zero offset of the framebuffer.
>>> +	 */
>>> +	if (afbc_en)
>>> +		offset = 0;
>>> +	else if (pstate->rotation & DRM_MODE_REFLECT_Y)
>>> +		offset += ((src->y2 >> 16) - 1) * fb->pitches[0];
>>> +	else
>>> +		offset += (src->y1 >> 16) * fb->pitches[0];
>>> +
>>> +	rk_obj = to_rockchip_obj(fb->obj[0]);
>>> +
>>> +	yrgb_mst = rk_obj->dma_addr + offset + fb->offsets[0];
>>> +	if (fb->format->is_yuv) {
>>> +		int hsub = fb->format->hsub;
>>> +		int vsub = fb->format->vsub;
>>> +
>>> +		offset = (src->x1 >> 16) * fb->format->cpp[1] / hsub;
>>> +		offset += (src->y1 >> 16) * fb->pitches[1] / vsub;
>>> +
>>> +		if ((pstate->rotation & DRM_MODE_REFLECT_Y) && !afbc_en)
>>> +			offset += fb->pitches[1] * ((pstate->src_h >> 16) - 2)  / vsub;
>>> +
>>> +		rk_obj = to_rockchip_obj(fb->obj[0]);
>>> +		uv_mst = rk_obj->dma_addr + offset + fb->offsets[1];
>>> +	}
>>> +
>>> +	actual_w = drm_rect_width(src) >> 16;
>>> +	actual_h = drm_rect_height(src) >> 16;
>>> +	dsp_w = drm_rect_width(dest);
>>> +
>>> +	if (dest->x1 + dsp_w > adjusted_mode->hdisplay) {
>>> +		drm_err(vop2->drm, "vp%d %s dest->x1[%d] + dsp_w[%d] exceed mode hdisplay[%d]\n",
>>> +			  vp->id, win->data->name, dest->x1, dsp_w, adjusted_mode->hdisplay);
>>> +		dsp_w = adjusted_mode->hdisplay - dest->x1;
>>> +		if (dsp_w < 4)
>>> +			dsp_w = 4;
>>> +		actual_w = dsp_w * actual_w / drm_rect_width(dest);
>>> +	}
>>> +
>>> +	dsp_h = drm_rect_height(dest);
>>> +
>>> +	if (dest->y1 + dsp_h > adjusted_mode->vdisplay) {
>>> +		drm_err(vop2->drm, "vp%d %s dest->y1[%d] + dsp_h[%d] exceed mode vdisplay[%d]\n",
>>> +			  vp->id, win->data->name, dest->y1, dsp_h, adjusted_mode->vdisplay);
>>> +		dsp_h = adjusted_mode->vdisplay - dest->y1;
>>> +		if (dsp_h < 4)
>>> +			dsp_h = 4;
>>> +		actual_h = dsp_h * actual_h / drm_rect_height(dest);
>>> +	}
>>> +
>>> +	/*
>>> +	 * This is workaround solution for IC design:
>>> +	 * esmart can't support scale down when actual_w % 16 == 1.
>>> +	 */
>>> +	if (!(win->data->feature & WIN_FEATURE_AFBDC)) {
>>> +		if (actual_w > dsp_w && (actual_w & 0xf) == 1) {
>>> +			drm_err(vop2->drm, "vp%d %s act_w[%d] MODE 16 == 1\n", vp->id, win->data->name, actual_w);
>>> +			actual_w -= 1;
>>> +		}
>>> +	}
>>> +
>>> +	if (afbc_en && actual_w % 4) {
>>> +		drm_err(vop2->drm, "vp%d %s actual_w[%d] should align as 4 pixel when enable afbc\n",
>>> +			  vp->id, win->data->name, actual_w);
>>> +		actual_w = ALIGN_DOWN(actual_w, 4);
>>> +	}
>>> +
>>> +	act_info = (actual_h - 1) << 16 | ((actual_w - 1) & 0xffff);
>>> +	dsp_info = (dsp_h - 1) << 16 | ((dsp_w - 1) & 0xffff);
>>> +
>>> +	format = vop2_convert_format(fb->format->format);
>>> +
>>> +	drm_dbg(vop2->drm, "vp%d update %s[%dx%d->%dx%d@%dx%d] fmt[%p4cc_%s] addr[%pad]\n",
>>> +		      vp->id, win->data->name, actual_w, actual_h, dsp_w, dsp_h,
>>> +		      dest->x1, dest->y1,
>>> +		      &fb->format->format,
>>> +		      afbc_en ? "AFBC" : "", &yrgb_mst);
>>> +
>>> +	if (afbc_en) {
>>> +		uint32_t stride;
>>> +
>>> +		/* the afbc superblock is 16 x 16 */
>>> +		afbc_format = vop2_convert_afbc_format(fb->format->format);
>>> +
>>> +		/* Enable color transform for YTR */
>>> +		if (fb->modifier & AFBC_FORMAT_MOD_YTR)
>>> +			afbc_format |= (1 << 4);
>>> +
>>> +		afbc_tile_num = ALIGN(actual_w, 16) >> 4;
>>> +
>>> +		/*
>>> +		 * AFBC pic_vir_width is count by pixel, this is different
>>> +		 * with WIN_VIR_STRIDE.
>>> +		 */
>>> +		stride = (fb->pitches[0] << 3) / bpp;
>>> +		if ((stride & 0x3f) && (xmirror || rotate_90 || rotate_270))
>>> +			drm_err(vop2->drm, "vp%d %s stride[%d] must align as 64 pixel when enable xmirror/rotate_90/rotate_270[0x%x]\n",
>>> +				  vp->id, win->data->name, stride, pstate->rotation);
>>> +
>>> +		rb_swap = vop2_afbc_rb_swap(fb->format->format);
>>> +		uv_swap = vop2_afbc_uv_swap(fb->format->format);
>>> +		/*
>>> +		 * This is a workaround for crazy IC design, Cluster
>>> +		 * and Esmart/Smart use different format configuration map:
>>> +		 * YUV420_10BIT: 0x10 for Cluster, 0x14 for Esmart/Smart.
>>> +		 *
>>> +		 * This is one thing we can make the convert simple:
>>> +		 * AFBCD decode all the YUV data to YUV444. So we just
>>> +		 * set all the yuv 10 bit to YUV444_10.
>>> +		 */
>>> +		if (fb->format->is_yuv && (bpp == 10))
>>> +			format = VOP2_CLUSTER_YUV444_10;
>>> +
>>> +		if (vop2_cluster_window(win))
>>> +			vop2_win_write(win, VOP2_WIN_AFBC_ENABLE, 1);
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_FORMAT, afbc_format);
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_RB_SWAP, rb_swap);
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_UV_SWAP, uv_swap);
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_AUTO_GATING_EN, 0);
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_BLOCK_SPLIT_EN, 0);
>>> +		if (pstate->rotation & (DRM_MODE_ROTATE_270 | DRM_MODE_ROTATE_90)) {
>>> +			vop2_win_write(win, VOP2_WIN_AFBC_HALF_BLOCK_EN, 0);
>>> +			transform_offset = vop2_afbc_transform_offset(pstate, false);
>>> +		} else {
>>> +			vop2_win_write(win, VOP2_WIN_AFBC_HALF_BLOCK_EN, 1);
>>> +			transform_offset = vop2_afbc_transform_offset(pstate, true);
>>> +		}
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_HDR_PTR, yrgb_mst);
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_PIC_SIZE, act_info);
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_TRANSFORM_OFFSET, transform_offset);
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_PIC_OFFSET, ((src->x1 >> 16) | src->y1));
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_DSP_OFFSET, (dest->x1 | (dest->y1 << 16)));
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_PIC_VIR_WIDTH, stride);
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_TILE_NUM, afbc_tile_num);
>>> +		vop2_win_write(win, VOP2_WIN_XMIRROR, xmirror);
>>
>> The xmirror's variable type is specified as bool, but it's not
>> true/false because in the above code:
>>
>> bool xmirror = pstate->rotation & DRM_MODE_REFLECT_X;
>>
>> I don't see how vop2_win_write() could work properly. Or am I missing
>> something?
> 
> Everything != 0 is true, so 0x10 & 0x10 is still true.

Ah, my bad. I keep forgetting that kernel uses _Bool.

> But ok,
> 
> 	bool xmirror = pstate->rotation & DRM_MODE_REFLECT_X ? true : false;
> 
> looks cleaner. I'll change that.
> 
> Thanks for the review so far. Could you drop me a short note when you're
> done? I was about to send v6.

I don't have any more comments, please feel free to send v6.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: Dmitry Osipenko <dmitry.osipenko@collabora.com>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: devicetree@vger.kernel.org,
	Benjamin Gaignard <benjamin.gaignard@collabora.com>,
	kernel@pengutronix.de, Sandy Huang <hjc@rock-chips.com>,
	dri-devel@lists.freedesktop.org,
	linux-rockchip@lists.infradead.org,
	Michael Riesch <michael.riesch@wolfvision.net>,
	Peter Geis <pgwipeout@gmail.com>,
	Andy Yan <andy.yan@rock-chips.com>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v5 22/23] drm: rockchip: Add VOP2 driver
Date: Wed, 16 Feb 2022 15:23:32 +0300	[thread overview]
Message-ID: <e560b6b3-c0e7-8e23-2490-154a2508c801@collabora.com> (raw)
In-Reply-To: <20220216112250.GN18637@pengutronix.de>



16.02.2022 14:22, Sascha Hauer пишет:
> On Wed, Feb 16, 2022 at 01:39:33PM +0300, Dmitry Osipenko wrote:
>> 09.02.2022 12:53, Sascha Hauer пишет:
>>> +static void vop2_plane_atomic_update(struct drm_plane *plane, struct drm_atomic_state *state)
>>> +{
>>> +	struct drm_plane_state *pstate = plane->state;
>>> +	struct drm_crtc *crtc = pstate->crtc;
>>> +	struct vop2_win *win = to_vop2_win(plane);
>>> +	struct vop2_video_port *vp = to_vop2_video_port(crtc);
>>> +	struct drm_display_mode *adjusted_mode = &crtc->state->adjusted_mode;
>>> +	struct vop2 *vop2 = win->vop2;
>>> +	struct drm_framebuffer *fb = pstate->fb;
>>> +	uint32_t bpp = fb->format->cpp[0] * 8;
>>> +	uint32_t actual_w, actual_h, dsp_w, dsp_h;
>>> +	uint32_t act_info, dsp_info;
>>> +	uint32_t format;
>>> +	uint32_t afbc_format;
>>> +	uint32_t rb_swap;
>>> +	uint32_t uv_swap;
>>> +	struct drm_rect *src = &pstate->src;
>>> +	struct drm_rect *dest = &pstate->dst;
>>> +	uint32_t afbc_tile_num;
>>> +	uint32_t transform_offset;
>>> +	bool dither_up;
>>> +	bool xmirror = pstate->rotation & DRM_MODE_REFLECT_X;
>>> +	bool ymirror = pstate->rotation & DRM_MODE_REFLECT_Y;
>>> +	bool rotate_270 = pstate->rotation & DRM_MODE_ROTATE_270;
>>> +	bool rotate_90 = pstate->rotation & DRM_MODE_ROTATE_90;
>>> +	struct rockchip_gem_object *rk_obj;
>>> +	unsigned long offset;
>>> +	bool afbc_en;
>>> +	dma_addr_t yrgb_mst;
>>> +	dma_addr_t uv_mst;
>>> +
>>> +	/*
>>> +	 * can't update plane when vop2 is disabled.
>>> +	 */
>>> +	if (WARN_ON(!crtc))
>>> +		return;
>>> +
>>> +	if (!pstate->visible) {
>>> +		vop2_plane_atomic_disable(plane, state);
>>> +		return;
>>> +	}
>>> +
>>> +	afbc_en = rockchip_afbc(plane, fb->modifier);
>>> +
>>> +	offset = (src->x1 >> 16) * fb->format->cpp[0];
>>> +
>>> +	/*
>>> +	 * AFBC HDR_PTR must set to the zero offset of the framebuffer.
>>> +	 */
>>> +	if (afbc_en)
>>> +		offset = 0;
>>> +	else if (pstate->rotation & DRM_MODE_REFLECT_Y)
>>> +		offset += ((src->y2 >> 16) - 1) * fb->pitches[0];
>>> +	else
>>> +		offset += (src->y1 >> 16) * fb->pitches[0];
>>> +
>>> +	rk_obj = to_rockchip_obj(fb->obj[0]);
>>> +
>>> +	yrgb_mst = rk_obj->dma_addr + offset + fb->offsets[0];
>>> +	if (fb->format->is_yuv) {
>>> +		int hsub = fb->format->hsub;
>>> +		int vsub = fb->format->vsub;
>>> +
>>> +		offset = (src->x1 >> 16) * fb->format->cpp[1] / hsub;
>>> +		offset += (src->y1 >> 16) * fb->pitches[1] / vsub;
>>> +
>>> +		if ((pstate->rotation & DRM_MODE_REFLECT_Y) && !afbc_en)
>>> +			offset += fb->pitches[1] * ((pstate->src_h >> 16) - 2)  / vsub;
>>> +
>>> +		rk_obj = to_rockchip_obj(fb->obj[0]);
>>> +		uv_mst = rk_obj->dma_addr + offset + fb->offsets[1];
>>> +	}
>>> +
>>> +	actual_w = drm_rect_width(src) >> 16;
>>> +	actual_h = drm_rect_height(src) >> 16;
>>> +	dsp_w = drm_rect_width(dest);
>>> +
>>> +	if (dest->x1 + dsp_w > adjusted_mode->hdisplay) {
>>> +		drm_err(vop2->drm, "vp%d %s dest->x1[%d] + dsp_w[%d] exceed mode hdisplay[%d]\n",
>>> +			  vp->id, win->data->name, dest->x1, dsp_w, adjusted_mode->hdisplay);
>>> +		dsp_w = adjusted_mode->hdisplay - dest->x1;
>>> +		if (dsp_w < 4)
>>> +			dsp_w = 4;
>>> +		actual_w = dsp_w * actual_w / drm_rect_width(dest);
>>> +	}
>>> +
>>> +	dsp_h = drm_rect_height(dest);
>>> +
>>> +	if (dest->y1 + dsp_h > adjusted_mode->vdisplay) {
>>> +		drm_err(vop2->drm, "vp%d %s dest->y1[%d] + dsp_h[%d] exceed mode vdisplay[%d]\n",
>>> +			  vp->id, win->data->name, dest->y1, dsp_h, adjusted_mode->vdisplay);
>>> +		dsp_h = adjusted_mode->vdisplay - dest->y1;
>>> +		if (dsp_h < 4)
>>> +			dsp_h = 4;
>>> +		actual_h = dsp_h * actual_h / drm_rect_height(dest);
>>> +	}
>>> +
>>> +	/*
>>> +	 * This is workaround solution for IC design:
>>> +	 * esmart can't support scale down when actual_w % 16 == 1.
>>> +	 */
>>> +	if (!(win->data->feature & WIN_FEATURE_AFBDC)) {
>>> +		if (actual_w > dsp_w && (actual_w & 0xf) == 1) {
>>> +			drm_err(vop2->drm, "vp%d %s act_w[%d] MODE 16 == 1\n", vp->id, win->data->name, actual_w);
>>> +			actual_w -= 1;
>>> +		}
>>> +	}
>>> +
>>> +	if (afbc_en && actual_w % 4) {
>>> +		drm_err(vop2->drm, "vp%d %s actual_w[%d] should align as 4 pixel when enable afbc\n",
>>> +			  vp->id, win->data->name, actual_w);
>>> +		actual_w = ALIGN_DOWN(actual_w, 4);
>>> +	}
>>> +
>>> +	act_info = (actual_h - 1) << 16 | ((actual_w - 1) & 0xffff);
>>> +	dsp_info = (dsp_h - 1) << 16 | ((dsp_w - 1) & 0xffff);
>>> +
>>> +	format = vop2_convert_format(fb->format->format);
>>> +
>>> +	drm_dbg(vop2->drm, "vp%d update %s[%dx%d->%dx%d@%dx%d] fmt[%p4cc_%s] addr[%pad]\n",
>>> +		      vp->id, win->data->name, actual_w, actual_h, dsp_w, dsp_h,
>>> +		      dest->x1, dest->y1,
>>> +		      &fb->format->format,
>>> +		      afbc_en ? "AFBC" : "", &yrgb_mst);
>>> +
>>> +	if (afbc_en) {
>>> +		uint32_t stride;
>>> +
>>> +		/* the afbc superblock is 16 x 16 */
>>> +		afbc_format = vop2_convert_afbc_format(fb->format->format);
>>> +
>>> +		/* Enable color transform for YTR */
>>> +		if (fb->modifier & AFBC_FORMAT_MOD_YTR)
>>> +			afbc_format |= (1 << 4);
>>> +
>>> +		afbc_tile_num = ALIGN(actual_w, 16) >> 4;
>>> +
>>> +		/*
>>> +		 * AFBC pic_vir_width is count by pixel, this is different
>>> +		 * with WIN_VIR_STRIDE.
>>> +		 */
>>> +		stride = (fb->pitches[0] << 3) / bpp;
>>> +		if ((stride & 0x3f) && (xmirror || rotate_90 || rotate_270))
>>> +			drm_err(vop2->drm, "vp%d %s stride[%d] must align as 64 pixel when enable xmirror/rotate_90/rotate_270[0x%x]\n",
>>> +				  vp->id, win->data->name, stride, pstate->rotation);
>>> +
>>> +		rb_swap = vop2_afbc_rb_swap(fb->format->format);
>>> +		uv_swap = vop2_afbc_uv_swap(fb->format->format);
>>> +		/*
>>> +		 * This is a workaround for crazy IC design, Cluster
>>> +		 * and Esmart/Smart use different format configuration map:
>>> +		 * YUV420_10BIT: 0x10 for Cluster, 0x14 for Esmart/Smart.
>>> +		 *
>>> +		 * This is one thing we can make the convert simple:
>>> +		 * AFBCD decode all the YUV data to YUV444. So we just
>>> +		 * set all the yuv 10 bit to YUV444_10.
>>> +		 */
>>> +		if (fb->format->is_yuv && (bpp == 10))
>>> +			format = VOP2_CLUSTER_YUV444_10;
>>> +
>>> +		if (vop2_cluster_window(win))
>>> +			vop2_win_write(win, VOP2_WIN_AFBC_ENABLE, 1);
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_FORMAT, afbc_format);
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_RB_SWAP, rb_swap);
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_UV_SWAP, uv_swap);
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_AUTO_GATING_EN, 0);
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_BLOCK_SPLIT_EN, 0);
>>> +		if (pstate->rotation & (DRM_MODE_ROTATE_270 | DRM_MODE_ROTATE_90)) {
>>> +			vop2_win_write(win, VOP2_WIN_AFBC_HALF_BLOCK_EN, 0);
>>> +			transform_offset = vop2_afbc_transform_offset(pstate, false);
>>> +		} else {
>>> +			vop2_win_write(win, VOP2_WIN_AFBC_HALF_BLOCK_EN, 1);
>>> +			transform_offset = vop2_afbc_transform_offset(pstate, true);
>>> +		}
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_HDR_PTR, yrgb_mst);
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_PIC_SIZE, act_info);
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_TRANSFORM_OFFSET, transform_offset);
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_PIC_OFFSET, ((src->x1 >> 16) | src->y1));
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_DSP_OFFSET, (dest->x1 | (dest->y1 << 16)));
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_PIC_VIR_WIDTH, stride);
>>> +		vop2_win_write(win, VOP2_WIN_AFBC_TILE_NUM, afbc_tile_num);
>>> +		vop2_win_write(win, VOP2_WIN_XMIRROR, xmirror);
>>
>> The xmirror's variable type is specified as bool, but it's not
>> true/false because in the above code:
>>
>> bool xmirror = pstate->rotation & DRM_MODE_REFLECT_X;
>>
>> I don't see how vop2_win_write() could work properly. Or am I missing
>> something?
> 
> Everything != 0 is true, so 0x10 & 0x10 is still true.

Ah, my bad. I keep forgetting that kernel uses _Bool.

> But ok,
> 
> 	bool xmirror = pstate->rotation & DRM_MODE_REFLECT_X ? true : false;
> 
> looks cleaner. I'll change that.
> 
> Thanks for the review so far. Could you drop me a short note when you're
> done? I was about to send v6.

I don't have any more comments, please feel free to send v6.

  reply	other threads:[~2022-02-16 12:23 UTC|newest]

Thread overview: 182+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-09  9:53 [PATCH v5 00/23] drm/rockchip: RK356x VOP2 support Sascha Hauer
2022-02-09  9:53 ` Sascha Hauer
2022-02-09  9:53 ` Sascha Hauer
2022-02-09  9:53 ` Sascha Hauer
2022-02-09  9:53 ` [PATCH v5 01/23] drm/encoder: Add of_graph port to struct drm_encoder Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09 10:07   ` Sascha Hauer
2022-02-09 10:07     ` Sascha Hauer
2022-02-09 10:07     ` Sascha Hauer
2022-02-09 10:07     ` Sascha Hauer
2022-02-09 11:12     ` Jani Nikula
2022-02-09 11:12       ` Jani Nikula
2022-02-09 11:12       ` Jani Nikula
2022-02-09 11:12       ` Jani Nikula
2022-02-10 11:52       ` Sascha Hauer
2022-02-10 11:52         ` Sascha Hauer
2022-02-10 11:52         ` Sascha Hauer
2022-02-10 11:52         ` Sascha Hauer
2022-02-10 15:22         ` Sascha Hauer
2022-02-10 15:22           ` Sascha Hauer
2022-02-10 15:22           ` Sascha Hauer
2022-02-10 15:22           ` Sascha Hauer
2022-02-09  9:53 ` [PATCH v5 02/23] drm/rockchip: dw_hdmi: Do not leave clock enabled in error case Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09 10:03   ` Heiko Stübner
2022-02-09 10:03     ` Heiko Stübner
2022-02-09 10:03     ` Heiko Stübner
2022-02-09 10:03     ` Heiko Stübner
2022-02-09  9:53 ` [PATCH v5 03/23] drm/rockchip: dw_hdmi: rename vpll clock to reference clock Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53 ` [PATCH v5 04/23] dt-bindings: display: rockchip: dw-hdmi: use "ref" as clock name Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53 ` [PATCH v5 05/23] arm64: dts: rockchip: rk3399: rename HDMI ref clock to 'ref' Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53 ` [PATCH v5 06/23] drm/rockchip: dw_hdmi: add rk3568 support Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53 ` [PATCH v5 07/23] dt-bindings: display: rockchip: dw-hdmi: Add compatible for rk3568 HDMI Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53 ` [PATCH v5 08/23] drm/rockchip: dw_hdmi: add regulator support Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53 ` [PATCH v5 09/23] dt-bindings: display: rockchip: dw-hdmi: Add " Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53 ` [PATCH v5 10/23] drm/rockchip: dw_hdmi: Add support for hclk Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-15 19:50   ` Dmitry Osipenko
2022-02-15 19:50     ` Dmitry Osipenko
2022-02-15 19:50     ` Dmitry Osipenko
2022-02-15 19:50     ` Dmitry Osipenko
2022-02-09  9:53 ` [PATCH v5 11/23] dt-bindings: display: rockchip: dw-hdmi: Add additional clock Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53 ` [PATCH v5 12/23] drm/rockchip: dw_hdmi: Use auto-generated tables Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09 10:06   ` Heiko Stübner
2022-02-09 10:06     ` Heiko Stübner
2022-02-09 10:06     ` Heiko Stübner
2022-02-09 10:06     ` Heiko Stübner
2022-02-09  9:53 ` [PATCH v5 13/23] drm/rockchip: dw_hdmi: drop mode_valid hook Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53 ` [PATCH v5 14/23] drm/rockchip: dw_hdmi: Set cur_ctr to 0 always Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53 ` [PATCH v5 15/23] drm/rockchip: dw_hdmi: add default 594Mhz clk for 4K@60hz Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53 ` [PATCH v5 16/23] dt-bindings: display: rockchip: dw-hdmi: Make unwedge pinctrl optional Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53 ` [PATCH v5 17/23] arm64: dts: rockchip: rk356x: Add VOP2 nodes Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53 ` [PATCH v5 18/23] arm64: dts: rockchip: rk356x: Add HDMI nodes Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53 ` [PATCH v5 19/23] arm64: dts: rockchip: rk3568-evb: Enable VOP2 and hdmi Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-10  0:10   ` Johan Jonker
2022-02-10  0:10     ` Johan Jonker
2022-02-10  0:10     ` Johan Jonker
2022-02-10  0:10     ` Johan Jonker
2022-02-10 11:47     ` Sascha Hauer
2022-02-10 11:47       ` Sascha Hauer
2022-02-10 11:47       ` Sascha Hauer
2022-02-10 11:47       ` Sascha Hauer
2022-02-10 13:15       ` Johan Jonker
2022-02-10 13:15         ` Johan Jonker
2022-02-10 13:15         ` Johan Jonker
2022-02-10 13:15         ` Johan Jonker
2022-02-10 13:37         ` Sascha Hauer
2022-02-10 13:37           ` Sascha Hauer
2022-02-10 13:37           ` Sascha Hauer
2022-02-10 13:37           ` Sascha Hauer
2022-02-10 13:51           ` Heiko Stübner
2022-02-10 13:51             ` Heiko Stübner
2022-02-10 13:51             ` Heiko Stübner
2022-02-10 13:51             ` Heiko Stübner
2022-02-09  9:53 ` [PATCH v5 20/23] arm64: dts: rockchip: enable vop2 and hdmi tx on quartz64a Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53 ` [PATCH v5 21/23] drm/rockchip: Make VOP driver optional Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53 ` [PATCH v5 22/23] drm: rockchip: Add VOP2 driver Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09 20:13   ` Aw: " Frank Wunderlich
2022-02-09 20:13     ` Frank Wunderlich
2022-02-09 20:13     ` Frank Wunderlich
2022-02-09 20:13     ` Frank Wunderlich
2022-02-10  6:50   ` Michael Riesch
2022-02-10  6:50     ` Michael Riesch
2022-02-10  6:50     ` Michael Riesch
2022-02-15 19:47   ` Dmitry Osipenko
2022-02-15 19:47     ` Dmitry Osipenko
2022-02-15 19:47     ` Dmitry Osipenko
2022-02-15 19:47     ` Dmitry Osipenko
2022-02-15 19:47   ` Dmitry Osipenko
2022-02-15 19:47     ` Dmitry Osipenko
2022-02-15 19:47     ` Dmitry Osipenko
2022-02-15 19:47     ` Dmitry Osipenko
2022-02-15 19:47   ` Dmitry Osipenko
2022-02-15 19:47     ` Dmitry Osipenko
2022-02-15 19:47     ` Dmitry Osipenko
2022-02-15 19:47     ` Dmitry Osipenko
2022-02-16 10:39   ` Dmitry Osipenko
2022-02-16 10:39     ` Dmitry Osipenko
2022-02-16 10:39     ` Dmitry Osipenko
2022-02-16 10:39     ` Dmitry Osipenko
2022-02-16 11:22     ` Sascha Hauer
2022-02-16 11:22       ` Sascha Hauer
2022-02-16 11:22       ` Sascha Hauer
2022-02-16 11:22       ` Sascha Hauer
2022-02-16 12:23       ` Dmitry Osipenko [this message]
2022-02-16 12:23         ` Dmitry Osipenko
2022-02-16 12:23         ` Dmitry Osipenko
2022-02-16 12:23         ` Dmitry Osipenko
2022-02-09  9:53 ` [PATCH v5 23/23] dt-bindings: display: rockchip: Add binding for VOP2 Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09  9:53   ` Sascha Hauer
2022-02-09 18:56   ` Rob Herring
2022-02-09 18:56     ` Rob Herring
2022-02-09 18:56     ` Rob Herring
2022-02-09 18:56     ` Rob Herring
2022-02-09 17:44 ` Aw: [PATCH v5 00/23] drm/rockchip: RK356x VOP2 support Frank Wunderlich
2022-02-09 17:44   ` Frank Wunderlich
2022-02-09 17:44   ` Frank Wunderlich
2022-02-09 17:44   ` Frank Wunderlich

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=e560b6b3-c0e7-8e23-2490-154a2508c801@collabora.com \
    --to=dmitry.osipenko@collabora.com \
    --cc=andy.yan@rock-chips.com \
    --cc=benjamin.gaignard@collabora.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hjc@rock-chips.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=michael.riesch@wolfvision.net \
    --cc=pgwipeout@gmail.com \
    --cc=s.hauer@pengutronix.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 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.