From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tomi Valkeinen Subject: Re: [PATCH v2 2/3] drm/omapdrm: Work-a-round for errata i734 (LCD1 Gamma) in DSS dispc Date: Mon, 23 May 2016 18:06:17 +0300 Message-ID: <57431C69.60709@ti.com> References: <6c6551b5f9543c954467448d3c4f71b74eca7c84.1464010715.git.jsarha@ti.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0476322813==" Return-path: Received: from bear.ext.ti.com (bear.ext.ti.com [198.47.19.11]) by gabe.freedesktop.org (Postfix) with ESMTPS id AD9736E33D for ; Mon, 23 May 2016 15:11:02 +0000 (UTC) In-Reply-To: <6c6551b5f9543c954467448d3c4f71b74eca7c84.1464010715.git.jsarha@ti.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To: Jyri Sarha , dri-devel@lists.freedesktop.org Cc: peter.ujfalusi@ti.com, laurent.pinchart@ideasonboard.com List-Id: dri-devel@lists.freedesktop.org --===============0476322813== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="HBXjw7lL9mJgw66AWjHTI9CA7S750bs8A" --HBXjw7lL9mJgw66AWjHTI9CA7S750bs8A Content-Type: multipart/mixed; boundary="38xWxfdqMSmTWLcKN60Mis3wk2nsdcmEx" From: Tomi Valkeinen To: Jyri Sarha , dri-devel@lists.freedesktop.org Cc: airlied@linux.ie, daniel@ffwll.ch, peter.ujfalusi@ti.com, bparrot@ti.com, laurent.pinchart@ideasonboard.com Message-ID: <57431C69.60709@ti.com> Subject: Re: [PATCH v2 2/3] drm/omapdrm: Work-a-round for errata i734 (LCD1 Gamma) in DSS dispc References: <6c6551b5f9543c954467448d3c4f71b74eca7c84.1464010715.git.jsarha@ti.com> In-Reply-To: <6c6551b5f9543c954467448d3c4f71b74eca7c84.1464010715.git.jsarha@ti.com> --38xWxfdqMSmTWLcKN60Mis3wk2nsdcmEx Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 23/05/16 17:41, Jyri Sarha wrote: > Work-a-round for errata i734 in DSS dispc I think it's "workaround" =3D). > - LCD1 Gamma Correction Is Not Working When GFX Pipe Is Disabled >=20 > For gamma tables to work on LCD1 the GFX plane has to be used at least > once after DSS HW has come out of reset. The work-a-round sets up a > minimal LCD setup with GFX plane and waits for one vertical sync irq > before disabling the setup and continuing with the context > restore. The physical outputs are gated during the operation. This > work-a-round requires that gamma table's LOADMODE is set to 0x2 in > DISPC_CONTROL1 register. This LOADMODE comment is a bit odd. You should say why, and how it's handled, and what's "0x2". But then, I'm not sure if the whole comment is needed at all. The driver is made to work only with LOADMODE=3D2. Maybe the real point here is that the WA needs to happen after the initial DSS register config. > For details see: > OMAP543x Multimedia Device Silicon Revision 2.0 Silicon Errata > Literature Number: SWPZ037E > Or some other relevant errata document for the DSS IP version. >=20 > Signed-off-by: Jyri Sarha > --- > drivers/gpu/drm/omapdrm/dss/dispc.c | 176 ++++++++++++++++++++++++++++= +++++++- > 1 file changed, 174 insertions(+), 2 deletions(-) >=20 > diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omap= drm/dss/dispc.c > index b284622..0e04bed 100644 > --- a/drivers/gpu/drm/omapdrm/dss/dispc.c > +++ b/drivers/gpu/drm/omapdrm/dss/dispc.c > @@ -115,6 +115,8 @@ struct dispc_features { > bool reverse_ilace_field_order:1; > =20 > bool has_gamma_table:1; > + > + bool has_gamma_i734_bug:1; > }; > =20 > #define DISPC_MAX_NR_FIFOS 5 > @@ -3931,7 +3933,7 @@ static int dispc_init_gamma_tables(void) > int channel; > =20 > if (!dispc.feat->has_gamma_table) > - return; > + return 0; This doesn't look like it belongs to this patch. > =20 > for (channel =3D 0; channel < ARRAY_SIZE(dispc.gamma_table); channel+= +) { > const struct dispc_gamma_desc *gdesc =3D &mgr_desc[channel].gamma; > @@ -4087,6 +4089,7 @@ static const struct dispc_features omap44xx_dispc= _feats =3D { > .supports_double_pixel =3D true, > .reverse_ilace_field_order =3D true, > .has_gamma_table =3D true, > + .has_gamma_i734_bug =3D true, > }; > =20 > static const struct dispc_features omap54xx_dispc_feats =3D { > @@ -4112,7 +4115,8 @@ static const struct dispc_features omap54xx_dispc= _feats =3D { > .has_writeback =3D true, > .supports_double_pixel =3D true, > .reverse_ilace_field_order =3D true, > - .has_gamma_tables =3D true, > + .has_gamma_table =3D true, > + .has_gamma_i734_bug =3D true, > }; > =20 > static int dispc_init_features(struct platform_device *pdev) > @@ -4204,6 +4208,166 @@ void dispc_free_irq(void *dev_id) > } > EXPORT_SYMBOL(dispc_free_irq); > =20 > +/* > + * Work-a-round for errata i734 in DSS dispc > + * - LCD1 Gamma Correction Is Not Working When GFX Pipe Is Disabled > + * > + * For gamma tables to work on LCD1 the GFX plane has to be used at > + * least once after DSS HW has come out of reset. The work-a-round > + * sets up a minimal LCD setup with GFX plane and waits for one > + * vertical sync irq before disabling the setup and continuing with > + * the context restore. The physical outputs are gated during the > + * operation. This work-a-round requires that gamma table's LOADMODE > + * is set to 0x2 in DISPC_CONTROL1 register. > + * > + * For details see: > + * OMAP543x Multimedia Device Silicon Revision 2.0 Silicon Errata > + * Literature Number: SWPZ037E > + * Or some other relevant errata document for the DSS IP version. > + */ > + > +static const struct dispc_errata_i734_data { > + struct omap_video_timings timings; > + struct omap_overlay_info ovli; > + struct omap_overlay_manager_info mgri; > + struct dss_lcd_mgr_config lcd_conf; > +} i734 =3D { > + .timings =3D { > + .x_res =3D 8, .y_res =3D 1, > + .pixelclock =3D 16000000, > + .hsw =3D 8, .hfp =3D 4, .hbp =3D 4, > + .vsw =3D 1, .vfp =3D 1, .vbp =3D 1, > + .vsync_level =3D OMAPDSS_SIG_ACTIVE_LOW, > + .hsync_level =3D OMAPDSS_SIG_ACTIVE_LOW, > + .interlace =3D false, > + .data_pclk_edge =3D OMAPDSS_DRIVE_SIG_RISING_EDGE, > + .de_level =3D OMAPDSS_SIG_ACTIVE_HIGH, > + .sync_pclk_edge =3D OMAPDSS_DRIVE_SIG_RISING_EDGE, > + .double_pixel =3D false, > + }, > + .ovli =3D { > + .screen_width =3D 1, > + .width =3D 1, .height =3D 1, > + .color_mode =3D OMAP_DSS_COLOR_RGB24U, > + .rotation =3D OMAP_DSS_ROT_0, > + .rotation_type =3D OMAP_DSS_ROT_DMA, > + .mirror =3D 0, > + .pos_x =3D 0, .pos_y =3D 0, > + .out_width =3D 0, .out_height =3D 0, > + .global_alpha =3D 0xff, > + .pre_mult_alpha =3D 0, > + .zorder =3D 0, > + }, > + .mgri =3D { > + .default_color =3D 0, > + .trans_enabled =3D false, > + .partial_alpha_enabled =3D false, > + .cpr_enable =3D false, > + }, > + .lcd_conf =3D { > + .io_pad_mode =3D DSS_IO_PAD_MODE_BYPASS, > + .stallmode =3D false, > + .fifohandcheck =3D false, > + .clock_info =3D { > + .lck_div =3D 1, > + .pck_div =3D 2, > + }, > + .video_port_width =3D 24, > + .lcden_sig_polarity =3D 0, > + }, > +}; > + > +static struct i734_buf { > + size_t size; > + dma_addr_t paddr; > + void *vaddr; > +} i734_buf; > + > +static int dispc_errata_i734_wa_init(void) > +{ > + if (!dispc.feat->has_gamma_i734_bug) > + return 0; > + > + i734_buf.size =3D i734.ovli.width * i734.ovli.height * > + color_mode_to_bpp(i734.ovli.color_mode) / 8; > + > + i734_buf.vaddr =3D dma_alloc_writecombine(&dispc.pdev->dev, i734_buf.= size, > + &i734_buf.paddr, GFP_KERNEL); > + if (IS_ERR(i734_buf.vaddr)) { Hmm I don't think dma_alloc_* returns an err ptr? > + dev_err(&dispc.pdev->dev, > + "%s: dma_alloc_writecombine failed: %ld\n", > + __func__, PTR_ERR(i734_buf.vaddr)); > + return PTR_ERR(i734_buf.vaddr); > + } > + > + return 0; > +} > + > +static void dispc_errata_i734_wa_fini(void) > +{ > + if (!dispc.feat->has_gamma_i734_bug) > + return; > + > + dma_free_writecombine(&dispc.pdev->dev, i734_buf.size, i734_buf.vaddr= , > + i734_buf.paddr); > +} > + > +static void dispc_errata_i734_wa(void) > +{ > + u32 framedone_irq =3D dispc_mgr_get_framedone_irq(OMAP_DSS_CHANNEL_LC= D); > + struct omap_overlay_info ovli; > + struct dss_lcd_mgr_config lcd_conf; > + u32 gatestate; > + unsigned int count; > + > + if (!dispc.feat->has_gamma_i734_bug) > + return; > + > + gatestate =3D REG_GET(DISPC_CONTROL, 8, 4); Still wrong register. > + > + ovli =3D i734.ovli; > + ovli.paddr =3D i734_buf.paddr; > + lcd_conf =3D i734.lcd_conf; > + > + /* Gate all LCD1 outputs */ > + REG_FLD_MOD(DISPC_CONFIG, 0x1f, 8, 4); > + > + /* Setup and enable GFX plane */ > + dispc_ovl_set_channel_out(OMAP_DSS_GFX, OMAP_DSS_CHANNEL_LCD); > + dispc_ovl_setup(OMAP_DSS_GFX, &ovli, false, &i734.timings, false); > + dispc_ovl_enable(OMAP_DSS_GFX, true); > + > + /* Set up and enable display manager for LCD1 */ > + dispc_mgr_setup(OMAP_DSS_CHANNEL_LCD, &i734.mgri); > + dispc_calc_clock_rates(dss_get_dispc_clk_rate(), > + &lcd_conf.clock_info); > + dispc_mgr_set_lcd_config(OMAP_DSS_CHANNEL_LCD, &lcd_conf); > + dispc_mgr_set_timings(OMAP_DSS_CHANNEL_LCD, &i734.timings); > + > + dispc_clear_irqstatus(framedone_irq); > + > + /* Enable and shut the channel to produce just one frame */ > + dispc_mgr_enable(OMAP_DSS_CHANNEL_LCD, true); > + dispc_mgr_enable(OMAP_DSS_CHANNEL_LCD, false); > + > + /* Busy wait for framedone (can't fiddle with irq handlers in resume)= */ > + count =3D 0; > + while (!(dispc_read_irqstatus() & framedone_irq)) > + if (count++ > 10000) { > + dev_err(&dispc.pdev->dev, "%s: framedone timeout\n", > + __func__); > + break; > + } Add { } for the 'while' too. Busyloops are always a bit tricky... I would perhaps change the loop above so that you first busy loop for a certain amount of loops, but after that udelay() for a short period in each loop. And it would be good to have a note here why busyloop is fine and what is the calculated time the frame takes. I mean, the reason why busy loop is preferred is what you mention, that we can't easily have a irq handler here, but the reason busyloop is fine is that the frame is so sma= ll. Tomi --38xWxfdqMSmTWLcKN60Mis3wk2nsdcmEx-- --HBXjw7lL9mJgw66AWjHTI9CA7S750bs8A Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJXQxxpAAoJEPo9qoy8lh71QrUQAI8DC4DBa1vtSIrfuENWXkQG /laslTfhu4DwxkpMq7f55188R/kmHlFj3x5+VUOVZ8o6vOdKW/7gUAhCl4ESgps7 7Gw9i3m+ipg5Cer+/Bi/CSAr6UtbXrG+C4YSgJYx02RhWs+D7yxgZo9r7f8bvDij 5CMuukiXQSDk9peWTNH1NXJHlGBNcVnwZZ2fYu9++1Or1H/Q7O2hdCIJkmCm0XPq mh8DJDYKPCvgcURgZjmAHCFMV/UGBO7nIt9pEhcUCBeHaTOJevWNzaVbS/Skj10Z xxpxn9DV4EqfCtqy933+qpiQSYn78CsPJNdN5A9BQSHPl3xTFRxMdFpkTrbZG4fR TZ2KS8m9zL3U+Bv/xFgVGpXP6KIA0P+j5oiC3lhodKVe8QC6xEVXZ1dRSfy3f9XV CABNee9r7fyT8SzZRvxQHhM2Fs2o3PGApTSFYom7/mWqIXx9LNgrfdyyCAuY2jhS to0MG16MbWjFO+a8H+3ubhT0/MZjfHTMIg4U2iUuiBqqsO8y+MWP+c94RHheUxoZ PYIRHBxgbRuJbWq0y8c1DBhIp/WaY3nuiW7Hfsr+D5A/kkBxOb8xtgbtGeQbqPhr fua9sNEhZyPbU6oOB0Ek5zhTY47QVNwzdRoqdzjXcWKc9l1p52BIErpLAtnjGEbn Wxsz0am/yON630remtmc =tGoa -----END PGP SIGNATURE----- --HBXjw7lL9mJgw66AWjHTI9CA7S750bs8A-- --===============0476322813== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KZHJpLWRldmVs IG1haWxpbmcgbGlzdApkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHBzOi8vbGlz dHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlzdGluZm8vZHJpLWRldmVsCg== --===============0476322813==--