From: Jyri Sarha <jsarha@ti.com>
To: Andrzej Hajda <a.hajda@samsung.com>,
alsa-devel@alsa-project.org, devicetree@vger.kernel.org,
dri-devel@lists.freedesktop.org
Cc: fabrizio.castro@bp.renesas.com, architt@codeaurora.org,
Songjun.Wu@atmel.com, peter.ujfalusi@ti.com,
tomi.valkeinen@ti.com, laurent.pinchart@ideasonboard.com,
voice.shen@atmel.com
Subject: Re: [PATCH v5 6/6] drm/bridge: sii902x: Implement HDMI audio support
Date: Mon, 15 Apr 2019 10:26:21 +0300 [thread overview]
Message-ID: <60b43760-fccd-4c3b-df7a-9afdde3f62a8@ti.com> (raw)
In-Reply-To: <e6fbf183-9f19-d749-0d87-54875957949f@samsung.com>
On 12/04/2019 15:30, Andrzej Hajda wrote:
>>>> +static const unsigned int sii902x_mclk_div_table[] = {
>>>> + 128, 256, 384, 512, 768, 1024, 1152, 192 };
>>>> +
>>>> +static int sii902x_select_mclk_div(u8 *i2s_config_reg, unsigned int rate,
>>>> + unsigned int mclk)
>>>> +{
>>>> + unsigned int div = mclk / rate;
>>>> + int distance = 100000;
>>>> + u8 i, nearest = 0;
>>>> +
>>>> + for (i = 0; i < ARRAY_SIZE(sii902x_mclk_div_table); i++) {
>>>> + unsigned int d = abs(div - sii902x_mclk_div_table[i]);
>>> Using unsigned types in this context seems to be asking for troubles.
>>>
>> Why? Isn't return value of abs() by definition unsigned? Using signed
>> integers when comparing absolute distances would seem awkward to me.
>
> (div - sii902x_mclk_div_table[i]) is unsigned, if div is lower, there is overflow, and the value is big int, I suppose this is not what you want.
>
Oh yes. I had my eyes fixed on wrong unsigned. The first operand of
subtraction should indeed be signed for the result to be signed, I
completely overlooked that.
Thanks,
Jyri
--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2019-04-15 7:26 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-22 8:06 [PATCH v5 0/6] drm/bridge: sii902x: HDMI-audio support and some fixes Jyri Sarha
2019-03-22 8:06 ` [PATCH v5 1/6] drm/bridge: sii902x: add input_bus_flags Jyri Sarha
2019-03-22 8:06 ` [PATCH v5 2/6] drm/bridge: sii902x: Set output mode to HDMI or DVI according to EDID Jyri Sarha
2019-03-22 8:06 ` [PATCH v5 3/6] drm/bridge: sii902x: pixel clock unit is 10kHz instead of 1kHz Jyri Sarha
2019-03-22 8:06 ` [PATCH v5 4/6] dt-bindings: display: sii902x: Remove trailing white space Jyri Sarha
2019-03-25 19:21 ` Rob Herring
2019-03-22 8:06 ` [PATCH v5 5/6] dt-bindings: display: sii902x: Add HDMI audio bindings Jyri Sarha
2019-04-20 23:08 ` Laurent Pinchart
2019-03-22 8:06 ` [PATCH v5 6/6] drm/bridge: sii902x: Implement HDMI audio support Jyri Sarha
2019-04-12 8:52 ` Andrzej Hajda
2019-04-12 11:53 ` Jyri Sarha
2019-04-12 12:30 ` Andrzej Hajda
2019-04-15 7:26 ` Jyri Sarha [this message]
2019-04-15 9:44 ` Andrzej Hajda
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=60b43760-fccd-4c3b-df7a-9afdde3f62a8@ti.com \
--to=jsarha@ti.com \
--cc=Songjun.Wu@atmel.com \
--cc=a.hajda@samsung.com \
--cc=alsa-devel@alsa-project.org \
--cc=architt@codeaurora.org \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=fabrizio.castro@bp.renesas.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=peter.ujfalusi@ti.com \
--cc=tomi.valkeinen@ti.com \
--cc=voice.shen@atmel.com \
/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).