devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "CK Hu (胡俊光)" <ck.hu@mediatek.com>
To: "robh+dt@kernel.org" <robh+dt@kernel.org>,
	"kishon@ti.com" <kishon@ti.com>,
	"Chunfeng Yun (云春峰)" <Chunfeng.Yun@mediatek.com>,
	"chunkuang.hu@kernel.org" <chunkuang.hu@kernel.org>,
	"Jitao Shi (石记涛)" <jitao.shi@mediatek.com>,
	"daniel@ffwll.ch" <daniel@ffwll.ch>,
	"granquet@baylibre.com" <granquet@baylibre.com>,
	"p.zabel@pengutronix.de" <p.zabel@pengutronix.de>,
	"airlied@gmail.com" <airlied@gmail.com>,
	"krzysztof.kozlowski+dt@linaro.org"
	<krzysztof.kozlowski+dt@linaro.org>,
	"vkoul@kernel.org" <vkoul@kernel.org>,
	"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-mediatek@lists.infradead.org"
	<linux-mediatek@lists.infradead.org>,
	"Mac Shen (沈俊)" <Mac.Shen@mediatek.com>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"krzysztof.kozlowski@linaro.org" <krzysztof.kozlowski@linaro.org>,
	"Stuart Lee (李翰)" <Stuart.Lee@mediatek.com>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"angelogioacchino.delregno@collabora.com"
	<angelogioacchino.delregno@collabora.com>
Subject: Re: [PATCH v4 5/8] drm/mediatek: hdmi: add v2 support
Date: Tue, 13 Jun 2023 02:19:10 +0000	[thread overview]
Message-ID: <72a13a42260d39c2495c59241d661f3a7a18c492.camel@mediatek.com> (raw)
In-Reply-To: <20220919-v4-5-687f09a06dd9@baylibre.com>

Hi, Guillaume:

On Mon, 2023-05-29 at 16:31 +0200, Guillaume Ranquet wrote:
>  	 
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
>  Adds hdmi and hdmi-ddc support for v2 IP.
> 
> Signed-off-by: Guillaume Ranquet <granquet@baylibre.com>
> ---

[snip]

> +
> +static bool fg_ddc_data_read(struct mtk_hdmi_ddc *ddc,
> +      unsigned char b_dev,
> +      unsigned char b_data_addr,
> +      unsigned char b_data_count,
> +      unsigned char *pr_data)
> +{
> +int ret;
> +
> +mutex_lock(&ddc->mtx);

Why do you need this mutex? fg_ddc_data_read() and fg_ddc_data_write()
are called by mtk_hdmi_ddc_xfer() which is the callback function of
master_xfer. In original hdmi driver, it's not necessary to use a mutex
to protect master_xfer, so I think this is not necessary.

Regards,
CK

> +
> +hdmi_ddc_request(ddc);
> +ret = vddc_read(ddc, DDC2_CLOK, b_dev, b_data_addr, SIF_8_BIT_HDMI,
> +      pr_data, b_data_count);
> +mutex_unlock(&ddc->mtx);
> +
> +return ret == b_data_count;
> +}
> +
> +static void fg_ddc_data_write(struct mtk_hdmi_ddc *ddc,
> +       unsigned char b_dev,
> +       unsigned char b_data_addr,
> +       unsigned char b_data_count,
> +       unsigned char *pr_data)
> +{
> +unsigned int i;
> +
> +mutex_lock(&ddc->mtx);
> +
> +hdmi_ddc_request(ddc);
> +for (i = 0; i < b_data_count; i++)
> +mtk_ddc_wr_one(ddc, b_dev, b_data_addr + i, *(pr_data + i));
> +
> +mutex_unlock(&ddc->mtx);
> +}
> +
> +static int mtk_hdmi_ddc_xfer(struct i2c_adapter *adapter, struct
> i2c_msg *msgs,
> +     int num)
> +{
> +struct mtk_hdmi_ddc *ddc = adapter->algo_data;
> +struct device *dev = adapter->dev.parent;
> +bool ret;
> +int i;
> +unsigned char offset;
> +
> +if (!ddc)
> +return -EINVAL;
> +
> +for (i = 0; i < num; i++) {
> +struct i2c_msg *msg = &msgs[i];
> +
> +if (msg->flags & I2C_M_RD) {
> +/* The underlying DDC hardware always issue a write request
> + * that assigns the read offset as part of the read operation.
> + * Therefore we need to use the offset value assigned
> + * in the previous write request from the drm_edid.c
> + */
> +ret = fg_ddc_data_read(ddc, msg->addr,
> +       offset, /* determined by previous write requests */
> +       (msg->len), &msg->buf[0]);
> +if (!ret) {
> +dev_err(dev, "ddc read failed : %d\n", ret);
> +return ret;
> +}
> +} else {
> +fg_ddc_data_write(ddc, msg->addr, msg->buf[0],
> +(msg->len - 1), &msg->buf[1]);
> +
> +/* we store the offset value requested by drm_edid framework
> + * to use in subsequent read requests.
> + */
> +if (DDC_ADDR == msg->addr && 1 == msg->len)
> +offset = msg->buf[0];
> +}
> +}
> +
> +return i;
> +}
> +

  parent reply	other threads:[~2023-06-13  2:19 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-29 14:30 [PATCH v4 0/8] Add MT8195 HDMI support Guillaume Ranquet
2023-05-29 14:30 ` [PATCH v4 1/8] dt-bindings: display: mediatek: add MT8195 hdmi bindings Guillaume Ranquet
2023-06-08 21:05   ` Rob Herring
2023-06-09 15:49     ` Guillaume Ranquet
2023-06-10  4:16       ` Chun-Kuang Hu
2023-05-29 14:30 ` [PATCH v4 2/8] drm/mediatek: hdmi: use a regmap instead of iomem Guillaume Ranquet
2023-05-29 14:31 ` [PATCH v4 3/8] drm/mediatek: extract common functions from the mtk hdmi driver Guillaume Ranquet
2023-06-13  2:37   ` CK Hu (胡俊光)
2023-05-29 14:31 ` [PATCH v4 4/8] drm/mediatek: hdmi: make the cec dev optional Guillaume Ranquet
2023-05-29 14:31 ` [PATCH v4 5/8] drm/mediatek: hdmi: add v2 support Guillaume Ranquet
2023-06-13  1:52   ` CK Hu (胡俊光)
2023-06-13  2:19   ` CK Hu (胡俊光) [this message]
2023-06-13  2:52   ` CK Hu (胡俊光)
2023-06-13  5:35   ` CK Hu (胡俊光)
2023-06-13  8:24   ` CK Hu (胡俊光)
2023-06-14  3:41   ` CK Hu (胡俊光)
2023-05-29 14:31 ` [PATCH v4 6/8] drm/mediatek: hdmi: v2: add audio support Guillaume Ranquet
2023-05-29 14:31 ` [PATCH v4 7/8] dt-bindings: display: mediatek: dpi: Add compatible for MediaTek MT8195 Guillaume Ranquet
2023-05-29 14:31 ` [PATCH v4 8/8] drm/mediatek: dpi: Add mt8195 hdmi to DPI driver Guillaume Ranquet
2023-06-14  6:14   ` CK Hu (胡俊光)
2024-01-15 11:06 ` [PATCH v4 0/8] Add MT8195 HDMI support AngeloGioacchino Del Regno

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=72a13a42260d39c2495c59241d661f3a7a18c492.camel@mediatek.com \
    --to=ck.hu@mediatek.com \
    --cc=Chunfeng.Yun@mediatek.com \
    --cc=Mac.Shen@mediatek.com \
    --cc=Stuart.Lee@mediatek.com \
    --cc=airlied@gmail.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=chunkuang.hu@kernel.org \
    --cc=daniel@ffwll.ch \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=granquet@baylibre.com \
    --cc=jitao.shi@mediatek.com \
    --cc=kishon@ti.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=p.zabel@pengutronix.de \
    --cc=robh+dt@kernel.org \
    --cc=vkoul@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).