mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-05 02:19:51 +00:00
media: mtk-cir: fix calculation of chk period
Since commit528222d853
("media: rc: harmonize infrared durations to microseconds"), the calculation of the chk period is wrong. As a result, all reported IR will have incorrect timings. Now that the calculations are done in microseconds rather than nanoseconds, we can fold the calculations in a simpler form with less rounding error. Tested-by: Frank Wunderlich <frank-w@public-files.de> Fixes:528222d853
("media: rc: harmonize infrared durations to microseconds") Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
This commit is contained in:
parent
44f28934af
commit
d904eb0b35
1 changed files with 3 additions and 6 deletions
|
@ -151,15 +151,12 @@ static inline u32 mtk_chk_period(struct mtk_ir *ir)
|
||||||
{
|
{
|
||||||
u32 val;
|
u32 val;
|
||||||
|
|
||||||
/* Period of raw software sampling in ns */
|
|
||||||
val = DIV_ROUND_CLOSEST(1000000000ul,
|
|
||||||
clk_get_rate(ir->bus) / ir->data->div);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Period for software decoder used in the
|
* Period for software decoder used in the
|
||||||
* unit of raw software sampling
|
* unit of raw software sampling
|
||||||
*/
|
*/
|
||||||
val = DIV_ROUND_CLOSEST(MTK_IR_SAMPLE, val);
|
val = DIV_ROUND_CLOSEST(clk_get_rate(ir->bus),
|
||||||
|
USEC_PER_SEC * ir->data->div / MTK_IR_SAMPLE);
|
||||||
|
|
||||||
dev_dbg(ir->dev, "@pwm clk = \t%lu\n",
|
dev_dbg(ir->dev, "@pwm clk = \t%lu\n",
|
||||||
clk_get_rate(ir->bus) / ir->data->div);
|
clk_get_rate(ir->bus) / ir->data->div);
|
||||||
|
@ -412,7 +409,7 @@ static int mtk_ir_probe(struct platform_device *pdev)
|
||||||
mtk_irq_enable(ir, MTK_IRINT_EN);
|
mtk_irq_enable(ir, MTK_IRINT_EN);
|
||||||
|
|
||||||
dev_info(dev, "Initialized MT7623 IR driver, sample period = %dus\n",
|
dev_info(dev, "Initialized MT7623 IR driver, sample period = %dus\n",
|
||||||
DIV_ROUND_CLOSEST(MTK_IR_SAMPLE, 1000));
|
MTK_IR_SAMPLE);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue