lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <37cdd403a4854f098c9d5e2a1bbbe3692f7576b7.camel@mediatek.com>
Date: Mon, 14 Oct 2024 09:40:12 +0000
From: CK Hu (胡俊光) <ck.hu@...iatek.com>
To: "sumit.semwal@...aro.org" <sumit.semwal@...aro.org>,
	"christian.koenig@....com" <christian.koenig@....com>, "mchehab@...nel.org"
	<mchehab@...nel.org>, "conor+dt@...nel.org" <conor+dt@...nel.org>,
	"robh@...nel.org" <robh@...nel.org>, "matthias.bgg@...il.com"
	<matthias.bgg@...il.com>, "krzk+dt@...nel.org" <krzk+dt@...nel.org>,
	AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>,
	Shu-hsiang Yang (楊舒翔)
	<Shu-hsiang.Yang@...iatek.com>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"linux-mediatek@...ts.infradead.org" <linux-mediatek@...ts.infradead.org>,
	"yunkec@...omium.org" <yunkec@...omium.org>, "linaro-mm-sig@...ts.linaro.org"
	<linaro-mm-sig@...ts.linaro.org>, "linux-media@...r.kernel.org"
	<linux-media@...r.kernel.org>, "devicetree@...r.kernel.org"
	<devicetree@...r.kernel.org>, Yaya Chang (張雅清)
	<Yaya.Chang@...iatek.com>, Project_Global_Chrome_Upstream_Group
	<Project_Global_Chrome_Upstream_Group@...iatek.com>,
	"dri-devel@...ts.freedesktop.org" <dri-devel@...ts.freedesktop.org>,
	Teddy Chen (陳乾元) <Teddy.Chen@...iatek.com>,
	"linux-arm-kernel@...ts.infradead.org"
	<linux-arm-kernel@...ts.infradead.org>, "hidenorik@...omium.org"
	<hidenorik@...omium.org>, Shun-Yi Wang (王順億)
	<Shun-Yi.Wang@...iatek.com>
Subject: Re: [PATCH v1 05/10] media: platform: mediatek: add isp_7x camsys
 unit

Hi, Shu-hsiang:

On Wed, 2024-10-09 at 19:15 +0800, Shu-hsiang Yang wrote:
> Introduces the top media device driver for the MediaTek ISP7X CAMSYS.
> The driver maintains the camera system, including sub-device management,
> DMA operations, and integration with the V4L2 framework. It handles
> request stream data, buffer management, and MediaTek-specific features,
> and pipeline management, streaming control, error handling mechanism.
> Additionally, it aggregates sub-drivers for the camera interface, raw
> and yuv pipelines.
> 
> Signed-off-by: Shu-hsiang Yang <Shu-hsiang.Yang@...iatek.com>
> ---

[snip]

> +
> +static int mtk_cam_fill_img_buf(struct mtkcam_ipi_img_output *img_out,
> +				const struct v4l2_format *f, dma_addr_t daddr)
> +{
> +	u32 pixelformat = f->fmt.pix_mp.pixelformat;
> +	u32 width = f->fmt.pix_mp.width;
> +	u32 height = f->fmt.pix_mp.height;
> +	const struct v4l2_plane_pix_format *plane = &f->fmt.pix_mp.plane_fmt[0];
> +	u32 stride = plane->bytesperline;
> +	u32 aligned_width;
> +	unsigned int addr_offset = 0;
> +	int i;
> +
> +	if (is_mtk_format(pixelformat)) {
> +		const struct mtk_format_info *info;
> +
> +		info = mtk_format_info(pixelformat);
> +		if (!info)
> +			return -EINVAL;
> +
> +		aligned_width = stride / info->bpp[0];
> +		if (info->mem_planes == 1) {
> +			if (is_yuv_ufo(pixelformat)) {
> +				aligned_width = ALIGN(width, 64);
> +				img_out->buf[0][0].iova = daddr;
> +				img_out->fmt.stride[0] = aligned_width * info->bit_r_num
> +							 / info->bit_r_den;
> +				img_out->buf[0][0].size = img_out->fmt.stride[0] * height;
> +				img_out->buf[0][0].size += img_out->fmt.stride[0] * height / 2;
> +				img_out->buf[0][0].size += ALIGN((aligned_width / 64), 8) * height;
> +				img_out->buf[0][0].size += ALIGN((aligned_width / 64), 8) * height
> +							   / 2;
> +				img_out->buf[0][0].size += sizeof(struct ufbc_buffer_header);
> +
> +				pr_debug("plane:%d stride:%d plane_size:%d addr:0x%lx\n",
> +					 0, img_out->fmt.stride[0], img_out->buf[0][0].size,
> +					 (unsigned long)img_out->buf[0][0].iova);
> +			} else if (is_raw_ufo(pixelformat)) {
> +				aligned_width = ALIGN(width, 64);
> +				img_out->buf[0][0].iova = daddr;
> +				img_out->fmt.stride[0] = aligned_width * info->bit_r_num /
> +							 info->bit_r_den;
> +				img_out->buf[0][0].size = img_out->fmt.stride[0] * height;
> +				img_out->buf[0][0].size += ALIGN((aligned_width / 64), 8) * height;
> +				img_out->buf[0][0].size += sizeof(struct ufbc_buffer_header);
> +
> +				pr_debug("plane:%d stride:%d plane_size:%d addr:0x%lx\n",
> +					 0, img_out->fmt.stride[0],
> +					 img_out->buf[0][0].size,
> +					 (unsigned long)img_out->buf[0][0].iova);
> +			} else {
> +				for (i = 0; i < info->comp_planes; i++) {
> +					unsigned int hdiv = (i == 0) ? 1 : info->hdiv;
> +					unsigned int vdiv = (i == 0) ? 1 : info->vdiv;
> +
> +					img_out->buf[0][i].iova = daddr + addr_offset;
> +					img_out->fmt.stride[i] = info->bpp[i] *
> +						DIV_ROUND_UP(aligned_width, hdiv);
> +					img_out->buf[0][i].size = img_out->fmt.stride[i]
> +						* DIV_ROUND_UP(height, vdiv);
> +					addr_offset += img_out->buf[0][i].size;
> +
> +					pr_debug("plane:%d stride:%d plane_size:%d addr:0x%lx\n",
> +						 i, img_out->fmt.stride[i],
> +						 img_out->buf[0][i].size,
> +						 (unsigned long)img_out->buf[0][i].iova);
> +				}
> +			}
> +		} else {
> +			pr_debug("do not support non contiguous mplane\n");
> +		}
> +	} else {
> +		const struct v4l2_format_info *info;
> +
> +		info = v4l2_format_info(pixelformat);
> +		if (!info)
> +			return -EINVAL;
> +
> +		aligned_width = stride / info->bpp[0];
> +		if (info->mem_planes == 1) {
> +			for (i = 0; i < info->comp_planes; i++) {

This for-loop is identical with the for-loop in is_mtk_format-is-true block.
So the checking of is_mtk_format is redundant.

Regards,
CK

> +				unsigned int hdiv = (i == 0) ? 1 : info->hdiv;
> +				unsigned int vdiv = (i == 0) ? 1 : info->vdiv;
> +
> +				img_out->buf[0][i].iova = daddr + addr_offset;
> +				img_out->fmt.stride[i] = info->bpp[i] *
> +					DIV_ROUND_UP(aligned_width, hdiv);
> +				img_out->buf[0][i].size = img_out->fmt.stride[i]
> +					* DIV_ROUND_UP(height, vdiv);
> +				addr_offset += img_out->buf[0][i].size;
> +
> +				pr_debug("stride:%d plane_size:%d addr:0x%lx\n",
> +					 img_out->fmt.stride[i],
> +					 img_out->buf[0][i].size,
> +					 (unsigned long)img_out->buf[0][i].iova);
> +			}
> +		} else {
> +			pr_debug("do not support non contiguous mplane\n");
> +		}
> +	}
> +
> +	return 0;
> +}
> +

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ