[PATCH v2 0/3] video: sunxi: Convert DM_VIDEO

161 views
Skip to first unread message

Jagan Teki

unread,
Jun 17, 2020, 4:25:08 PM6/17/20
to Anatolij Gustschin, Maxime Ripard, u-b...@lists.denx.de, Hans de Goede, Zoltan Herpai, Aleksei Mamlin, Priit Laes, Paul Kocialkowski, Chen-Yu Tsai, Phil Han, Siarhei Siamashka, Peter Korsgaard, Stefan Mavrodiev, Icenowy Zheng, Quentin Schulz, FUKAUMI Naoki, Marcus Cooper, Stefan Mavrodiev, Iain Paton, Olliver Schinagl, Ian Campbell, Stefan Roese, Jelle de Jong, Adam Sampson, Tom Rini, linux...@googlegroups.com, linux-...@amarulasolutions.com, Jagan Teki
These series supports DM_VIDEO conversation for missing
sunxi platforms. Separate splash screen support is required
since the video log support in legacy drivers are not
supporting with driver mode video.

Dependencies:
http://patchwork.ozlabs.org/project/uboot/list/?series=182476
http://patchwork.ozlabs.org/project/uboot/list/?series=182477
http://patchwork.ozlabs.org/project/uboot/list/?series=182478

Changes for v2:
- new splash screen support patches

Any inputs?
Jagan.

Jagan Teki (3):
logos: Add sunxi logo
sunxi: Enable splash screen support
video: sunxi_display: Convert to DM_VIDEO

arch/arm/mach-sunxi/Kconfig | 4 +-
drivers/video/sunxi/sunxi_display.c | 264 ++++++++++++++++------------
include/configs/sunxi-common.h | 26 ++-
scripts/config_whitelist.txt | 1 -
tools/logos/sunxi.bmp | Bin 0 -> 11018 bytes
5 files changed, 167 insertions(+), 128 deletions(-)
create mode 100644 tools/logos/sunxi.bmp

--
2.25.1

Jagan Teki

unread,
Jun 17, 2020, 4:25:16 PM6/17/20
to Anatolij Gustschin, Maxime Ripard, u-b...@lists.denx.de, Hans de Goede, Zoltan Herpai, Aleksei Mamlin, Priit Laes, Paul Kocialkowski, Chen-Yu Tsai, Phil Han, Siarhei Siamashka, Peter Korsgaard, Stefan Mavrodiev, Icenowy Zheng, Quentin Schulz, FUKAUMI Naoki, Marcus Cooper, Stefan Mavrodiev, Iain Paton, Olliver Schinagl, Ian Campbell, Stefan Roese, Jelle de Jong, Adam Sampson, Tom Rini, linux...@googlegroups.com, linux-...@amarulasolutions.com, Jagan Teki
Add sunxi logo which would be used for splash screen support.

The original images were the crapped version from linux-sunxi.org
and generated using below step

$ convert sunxi.jpg -type Palette -colors 224 -depth 8 \
-compress none -verbose BMP3:tools/logos/sunxi.bmp

Signed-off-by: Jagan Teki <ja...@amarulasolutions.com>
---
Changes for v2:
- new patch

tools/logos/sunxi.bmp | Bin 0 -> 11018 bytes
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 tools/logos/sunxi.bmp

diff --git a/tools/logos/sunxi.bmp b/tools/logos/sunxi.bmp
new file mode 100644
index 0000000000000000000000000000000000000000..87dfea0c4fe2c7cf805e042cb20e54c1481b02c6
GIT binary patch
literal 11018
zcmeHNduUV55+5JO$5G?a_=q7y6Jiau#u}U3P-{&>jiIrmgxW$vsv(3EN(d!2h9D6m
zkppr?5fnu94-rH}K@da~K}12sKg6pb3W|sbqWHk~>(1<+lP@Y?8^3b@xR9wiXLfdW
z=C`x6vzwr=TU-i^{xuQ6j@-ZTvkpJwU<#A}r-8lrV;t*X{J3%BVEp*;Fk!+3m^g7F
z2!a5UCQX9LlPANJDN|tT)TuCS+B6VF5vEU{4l`!VfSEIAf+R^WYt}57J$p9j^?H~y
zXAaDrI~V57n+Nmf&xZvI7J$)c1e3`GX0sU<E?fwU7A*p+)e4IjFNP&cmVn)EhowuG
z!m?${VEOXpuwumuSh;c~w6?Z_%jE*M+YPH$t%5ac*1+o3tHI~<fyd*4wQJYHx^?TI
ztE&svuU`+LPzZW@dLSGQLtkGXY}l{?B9REhVlmjbaU*Qnv<VW41SFG5kYyQCsT2$j
z4niiAfowJlTefV0&6_vF)~#EiP$)pLScGlcw!!x8+hNC!9k6rfPS~|;7wq1>8}{tk
z1AF)Gg?;<>!T$aG;lP0daPZ(kICSU`96o#)jvP4xM~@zb<HwJ~v17;J#EBDd^5jW4
zb?OwHK7AU_oH+yM&Ygp^XV1d<^XK8hg$r=;;zhW0=@MMNd>O7>xdK<OUWIGduEF)|
z*Wt#E8*uaHO}KUI7Tmsl8}8h>19$J<h5PsK!@Ya=;K73j@bKY7c=YHIJbwHbo;-O1
zPoF-8XV0F&^XJdu#fum4^5si-{rWY$di4t4ym<p}-@b)+@7}?O4<F$D`}gqi<45@P
z=@WeZ{29J{`2t_ReuZz}zQOnJ-{HrPA61D{XX_EDN1z^odIahbs7Ih4fqDe$5%|Xu
z5ZFlm)QnWikY~-GH8jnC@UAwl4kuByea2S{s@(jIxJqLzY{j}jfcQVMSCJz}{9ip|
z@%Gc$zg+yS7{3*&NPbfmKs1=FCh@n9pNx&Q!L4gPw6|teFge>jUSA^^0<l=!Yt-cb
zlXu0r-e@tK1(57bP0h`AkvYT8&UB%uWL#iQDT)$psHl$>41G1PB2kod+$Re4-e9;t
zYyewgxU7^1Z73pTgNzWAfDUv?e8;PQ1E{j}=d8|Xvl?}kafY@~B<5%6FiD+RrC1)e
zfWD(h-hC3&({<#qQD{M2h@~vkj}$f1Pt(RRyiHG?BhVjDB;|NKVB^~Z%)RI*CZZB5
zSo+HZ0q1QRATHm+T$*TQ${`bK#F0xoY6PNs7EKKfce}gYY2#C4c=VoBNnzfUVx*OK
znEOhKl2qf=f;@V~d5cYh#74~ovX$X#Bm^-OW}9opLVAL(B{V>BRdUhxO4jSUn25wk
z`F2tSV+dCx%@aoI;$3Xs0a~R}2$gJ6#8Qmt$#NeGaj|M841v_0=T`AqOjub^Kpz;c
z2#JZaW!L))I8z=M=O7On^JVHKrIbSi7M8Sw>GYti+*&IXoUCa8?N_K6vs0kK%AutD
zLw!TkS?(f}dLP2h8kqH<I;M@aTueVM3FKdi^3ZkDD!N&JO%J`FPp^<=n?X@<o8Vs?
znJk5zW{ah1fcTgZ#Zo(AG1GEcnG`!bECiB=l!_gllsQ?%N8t_7ENOLXq!vnxQYI4c
zboQnRR<a34n#0JI<9vE8X>4TN*brT)J#0rmBJ+cCrIV$GV2n`^GAukjC?YIgvhA%A
z2>!~*LOs~bygFqZTMVEfdjh#^8^<E}u#xkldC`H^^A7YQ(atRr_AX3!0@ski2BQ*R
zHh}glwtcl?0dqg9XT3BFByy_sBGV)z6W6Qa7HpKl)M&(c=UPM_pi&=2p~plcaan`f
z7U;8*1j$VS?c)5XPXQb<sz+3F;G#T@;xGqIdq9N(4w`?IT9ndxw*(eik(`5arq`mn
zG16{ED!JGKAwDNr3G(2MiUpvJB8#iSsg)L(u(0Aaz=Z<XNt`5`MvQs^v(-s%69Q#b
z6we_J+R0X_oMPZe)I<joB~NYC5=qKgw(T&=QV7Q?5wap9qoyuE1I;f@`$bP!{Gz@a
z1vwAU2IiHA@JN1aDy29r5kuDy$95kJ`siqIgeZwRJ}to>VL_(q*+{t?=S2+!YaCZ3
zLuEz83@8Le2PI|P2tgbm)4pS5WK+RitX-e1bO=PW?9tRleiIh6FUAWg6$h|WCL|;^
z_?9SQ8N#vxIvICQNY8S-8w&{5q>Mw=;@O7dhUf?)o2Cf123W<$*2qNqEGCk}KcMY`
zkRD|=vXV5ZmlsnX`pnWrL`00mUN`looVf3B&@jG<1W?1GD0rtqv$$w<GQ=x!<9Z`L
z1;G|zRSpND3pUhDR#JFXU}Wk>EW=b*M7$@Iq64&-1DMP0$P}~#r&&g6o~D%V<l{uj
zCt1ZhA_g@kxFD1qoQg?)4KvXkQ;jMX1Fc2QiRmMT@g9-JmQtiMv5g7{KX3#HQ?_-p
z;H1<OmQp;eVI2hwb&FQYc1|gek-In2g&^ImV$pl?V9B`&O9(kk9^4+Zb6s@$umeW`
z3vITN!zLr7Vn5%=WMxRJ!lPiJV^ANaX(FY2JM3C5kSIHcT6vigq&C9hmGBVo^Ry}}
zbcY1CEFH{=o_b0V3%Cesk$?lxCLi{&{?Q+3uaOQ@B`=3u1{MZ-2x14yvK?y4)Va`4
zAwVadmr?~uW>uq+Lh56QYNJ9|aN>Q75?vW&X-6|Es>w4t7~qF}zMFO|h<c;JM5hqD
zGYtDwEJ8D4DF%%wXU82*ww+x%Z83D_XCn!`B2x`wi&YL%h?%fb)k$w85)2f_oR=?-
zJ(|la5klZ1DSofuWG5_P%q78{VfAp3oC;v3&D}*hb}IK-0x$4uORfXC4pI)XaC1W=
zKg~U;FXJ~ZswHmp$<8BiAXDhpuvqaxDzX#QNjpa=^`KE4VxSvsh_JJ(RFY@Dfe<S6
zWyC|d6C4?U+Dm{9wC{$R$R6m3SNe%<K&BXG3xO>oW=UxPulWKys1&)8bZ`I_kY0?D
zElMNl^dM?U%1OBwbI020_j+rrb(9%yj7ur*Fq%vjKOHkAw*Cz`qY}T(qj8C_r0`%7
zY_t{?r_iMolpe(5PGmDfeVSLPp}EOs!Swo5Y9IhgKG7e?Z=y(a2f&L8?Jhi!IO%AU
zWT*_AY3B^PNla074}?Q4sAY3Bm<+heBpU-s0ZJ03T%@%{;^o4UMPP$!xe+9+X*rpy
zo8;{c`uXlBzmmzI$Fc)DQJ_^uZVYH}D#jkQ*ddT|+RsC4No0pJR6Ut(vDxi*IdJ}1
zJ}d?;S{28?`~O{1W3(*6be@){n9D@*{>Vsb?dWjRX-K45t~9F_L+ewuu*o|a!-xOT
zQ?Li3@}S)BZ>F+=RB_7rignhhJxEFWRB`H9P3w=}f~3R$&!7`oJ<*KeTVt!aDg?iD
zYfbI_$1tkgFdM3&DtlEdfvax*;%$VkUo`8@dIahbs7Ih4fqDe$5vWJt|1Sdn1vprt
AKL7v#

literal 0
HcmV?d00001

--
2.25.1

Jagan Teki

unread,
Jun 17, 2020, 4:25:28 PM6/17/20
to Anatolij Gustschin, Maxime Ripard, u-b...@lists.denx.de, Hans de Goede, Zoltan Herpai, Aleksei Mamlin, Priit Laes, Paul Kocialkowski, Chen-Yu Tsai, Phil Han, Siarhei Siamashka, Peter Korsgaard, Stefan Mavrodiev, Icenowy Zheng, Quentin Schulz, FUKAUMI Naoki, Marcus Cooper, Stefan Mavrodiev, Iain Paton, Olliver Schinagl, Ian Campbell, Stefan Roese, Jelle de Jong, Adam Sampson, Tom Rini, linux...@googlegroups.com, linux-...@amarulasolutions.com, Jagan Teki
Enable splash screen support for sunxi platforms.

The splash screen image, sunxi.bmp would load left corner
on screen in 0,0 splash position. This is default legacy
logo position on sunxi platform and also it would be common
practice to have at 0,0 since the default sunx.bmp is nominal
size.

Signed-off-by: Jagan Teki <ja...@amarulasolutions.com>
---
Changes for v2:
- new patch

include/configs/sunxi-common.h | 11 +++++++++++
1 file changed, 11 insertions(+)

diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
index 5b0bec0561..308d7a42aa 100644
--- a/include/configs/sunxi-common.h
+++ b/include/configs/sunxi-common.h
@@ -270,6 +270,15 @@ extern int soft_i2c_gpio_scl;

#endif /* CONFIG_VIDEO_SUNXI */

+#if CONFIG_IS_ENABLED(CMD_BMP)
+# define CONFIG_VIDEO_BMP_RLE8
+# define CONFIG_SPLASH_SCREEN
+# define CONFIG_SPLASH_SCREEN_ALIGN
+# define CONFIG_BMP_16BPP
+# define CONFIG_VIDEO_LOGO
+# define CONFIG_VIDEO_BMP_LOGO
+#endif
+
/* Ethernet support */

#ifdef CONFIG_USB_EHCI_HCD
@@ -475,6 +484,8 @@ extern int soft_i2c_gpio_scl;
#endif

#define CONSOLE_ENV_SETTINGS \
+ "splashpos=0,0\0" \
+ "splashimage=" __stringify(CONFIG_SYS_LOAD_ADDR) "\0" \
CONSOLE_STDIN_SETTINGS \
CONSOLE_STDOUT_SETTINGS

--
2.25.1

Jagan Teki

unread,
Jun 17, 2020, 4:25:36 PM6/17/20
to Anatolij Gustschin, Maxime Ripard, u-b...@lists.denx.de, Hans de Goede, Zoltan Herpai, Aleksei Mamlin, Priit Laes, Paul Kocialkowski, Chen-Yu Tsai, Phil Han, Siarhei Siamashka, Peter Korsgaard, Stefan Mavrodiev, Icenowy Zheng, Quentin Schulz, FUKAUMI Naoki, Marcus Cooper, Stefan Mavrodiev, Iain Paton, Olliver Schinagl, Ian Campbell, Stefan Roese, Jelle de Jong, Adam Sampson, Tom Rini, linux...@googlegroups.com, linux-...@amarulasolutions.com, Jagan Teki
DM_VIDEO migration deadline is already expired, but around
80 Allwinner boards are still using video in a legacy way.

===================== WARNING ======================
This board does not use CONFIG_DM_VIDEO Please update
the board to use CONFIG_DM_VIDEO before the v2019.07 release.
Failure to update by the deadline may result in board removal.
See doc/driver-model/migration.rst for more info.
====================================================

So let's live these boards on the tree before the video maintainer
removes it by converting in to DM_VIDEO.

Tested in Bananapi M1+ Plus 1920x1200 HDMI out.

Signed-off-by: Jagan Teki <ja...@amarulasolutions.com>
---
Changes for v2:
- add BMP support

arch/arm/mach-sunxi/Kconfig | 4 +-
drivers/video/sunxi/sunxi_display.c | 264 ++++++++++++++++------------
include/configs/sunxi-common.h | 17 --
scripts/config_whitelist.txt | 1 -
4 files changed, 157 insertions(+), 129 deletions(-)

diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
index be0822bfb7..7d2fb55ff0 100644
--- a/arch/arm/mach-sunxi/Kconfig
+++ b/arch/arm/mach-sunxi/Kconfig
@@ -758,8 +758,10 @@ config VIDEO_SUNXI
depends on !MACH_SUN9I
depends on !MACH_SUN50I
depends on !MACH_SUN50I_H6
- select VIDEO
+ select DM_VIDEO
+ select DISPLAY
imply VIDEO_DT_SIMPLEFB
+ imply CMD_BMP
default y
---help---
Say Y here to add support for using a cfb console on the HDMI, LCD
diff --git a/drivers/video/sunxi/sunxi_display.c b/drivers/video/sunxi/sunxi_display.c
index f52aba4d21..fb51b0c5ba 100644
--- a/drivers/video/sunxi/sunxi_display.c
+++ b/drivers/video/sunxi/sunxi_display.c
@@ -7,6 +7,8 @@
*/

#include <common.h>
+#include <display.h>
+#include <dm.h>
#include <cpu_func.h>
#include <efi_loader.h>
#include <init.h>
@@ -28,7 +30,9 @@
#include <fdt_support.h>
#include <i2c.h>
#include <malloc.h>
+#include <video.h>
#include <video_fb.h>
+#include <dm/uclass-internal.h>
#include "../videomodes.h"
#include "../anx9804.h"
#include "../hitachi_tx18d42vm_lcd.h"
@@ -45,6 +49,13 @@

DECLARE_GLOBAL_DATA_PTR;

+enum {
+ /* Maximum LCD size we support */
+ LCD_MAX_WIDTH = 3840,
+ LCD_MAX_HEIGHT = 2160,
+ LCD_MAX_LOG2_BPP = VIDEO_BPP32,
+};
+
enum sunxi_monitor {
sunxi_monitor_none,
sunxi_monitor_dvi,
@@ -59,12 +70,11 @@ enum sunxi_monitor {
#define SUNXI_MONITOR_LAST sunxi_monitor_composite_pal_nc

struct sunxi_display {
- GraphicDevice graphic_device;
enum sunxi_monitor monitor;
unsigned int depth;
unsigned int fb_addr;
unsigned int fb_size;
-} sunxi_display;
+};

const struct ctfb_res_modes composite_video_modes[2] = {
/* x y hz pixclk ps/kHz le ri up lo hs vs s vmode */
@@ -214,7 +224,8 @@ static int sunxi_hdmi_edid_get_block(int block, u8 *buf)
return r;
}

-static int sunxi_hdmi_edid_get_mode(struct ctfb_res_modes *mode,
+static int sunxi_hdmi_edid_get_mode(struct sunxi_display *sunxi_display,
+ struct ctfb_res_modes *mode,
bool verbose_mode)
{
struct edid1_info edid1;
@@ -291,14 +302,14 @@ static int sunxi_hdmi_edid_get_mode(struct ctfb_res_modes *mode,
}

/* Check for basic audio support, if found enable hdmi output */
- sunxi_display.monitor = sunxi_monitor_dvi;
+ sunxi_display->monitor = sunxi_monitor_dvi;
for (i = 0; i < ext_blocks; i++) {
if (cea681[i].extension_tag != EDID_CEA861_EXTENSION_TAG ||
cea681[i].revision < 2)
continue;

if (EDID_CEA861_SUPPORTS_BASIC_AUDIO(cea681[i]))
- sunxi_display.monitor = sunxi_monitor_hdmi;
+ sunxi_display->monitor = sunxi_monitor_hdmi;
}

return 0;
@@ -414,9 +425,9 @@ static void sunxi_frontend_mode_set(const struct ctfb_res_modes *mode,
static void sunxi_frontend_enable(void) {}
#endif

-static bool sunxi_is_composite(void)
+static bool sunxi_is_composite(enum sunxi_monitor monitor)
{
- switch (sunxi_display.monitor) {
+ switch (monitor) {
case sunxi_monitor_none:
case sunxi_monitor_dvi:
case sunxi_monitor_hdmi:
@@ -473,7 +484,8 @@ static const u32 sunxi_rgb2yuv_coef[12] = {
};

static void sunxi_composer_mode_set(const struct ctfb_res_modes *mode,
- unsigned int address)
+ unsigned int address,
+ enum sunxi_monitor monitor)
{
struct sunxi_de_be_reg * const de_be =
(struct sunxi_de_be_reg *)SUNXI_DE_BE0_BASE;
@@ -502,7 +514,7 @@ static void sunxi_composer_mode_set(const struct ctfb_res_modes *mode,
#endif
SUNXI_DE_BE_MODE_INTERLACE_ENABLE);

- if (sunxi_is_composite()) {
+ if (sunxi_is_composite(monitor)) {
writel(SUNXI_DE_BE_OUTPUT_COLOR_CTRL_ENABLE,
&de_be->output_color_ctrl);
for (i = 0; i < 12; i++)
@@ -616,7 +628,8 @@ static void sunxi_lcdc_backlight_enable(void)
gpio_direction_output(pin, PWM_ON);
}

-static void sunxi_lcdc_tcon0_mode_set(const struct ctfb_res_modes *mode,
+static void sunxi_lcdc_tcon0_mode_set(struct sunxi_display *sunxi_display,
+ const struct ctfb_res_modes *mode,
bool for_ext_vga_dac)
{
struct sunxi_lcdc_reg * const lcdc =
@@ -643,17 +656,18 @@ static void sunxi_lcdc_tcon0_mode_set(const struct ctfb_res_modes *mode,
}

lcdc_pll_set(ccm, 0, mode->pixclock_khz, &clk_div, &clk_double,
- sunxi_is_composite());
+ sunxi_is_composite(sunxi_display->monitor));

video_ctfb_mode_to_display_timing(mode, &timing);
lcdc_tcon0_mode_set(lcdc, &timing, clk_div, for_ext_vga_dac,
- sunxi_display.depth, CONFIG_VIDEO_LCD_DCLK_PHASE);
+ sunxi_display->depth, CONFIG_VIDEO_LCD_DCLK_PHASE);
}

#if defined CONFIG_VIDEO_HDMI || defined CONFIG_VIDEO_VGA || defined CONFIG_VIDEO_COMPOSITE
static void sunxi_lcdc_tcon1_mode_set(const struct ctfb_res_modes *mode,
int *clk_div, int *clk_double,
- bool use_portd_hvsync)
+ bool use_portd_hvsync,
+ enum sunxi_monitor monitor)
{
struct sunxi_lcdc_reg * const lcdc =
(struct sunxi_lcdc_reg *)SUNXI_LCD0_BASE;
@@ -663,7 +677,7 @@ static void sunxi_lcdc_tcon1_mode_set(const struct ctfb_res_modes *mode,

video_ctfb_mode_to_display_timing(mode, &timing);
lcdc_tcon1_mode_set(lcdc, &timing, use_portd_hvsync,
- sunxi_is_composite());
+ sunxi_is_composite(monitor));

if (use_portd_hvsync) {
sunxi_gpio_set_cfgpin(SUNXI_GPD(26), SUNXI_GPD_LCD0);
@@ -671,7 +685,7 @@ static void sunxi_lcdc_tcon1_mode_set(const struct ctfb_res_modes *mode,
}

lcdc_pll_set(ccm, 1, mode->pixclock_khz, clk_div, clk_double,
- sunxi_is_composite());
+ sunxi_is_composite(monitor));
}
#endif /* CONFIG_VIDEO_HDMI || defined CONFIG_VIDEO_VGA || CONFIG_VIDEO_COMPOSITE */

@@ -725,7 +739,8 @@ static void sunxi_hdmi_setup_info_frames(const struct ctfb_res_modes *mode)
}

static void sunxi_hdmi_mode_set(const struct ctfb_res_modes *mode,
- int clk_div, int clk_double)
+ int clk_div, int clk_double,
+ enum sunxi_monitor monitor)
{
struct sunxi_hdmi_reg * const hdmi =
(struct sunxi_hdmi_reg *)SUNXI_HDMI_BASE;
@@ -734,7 +749,7 @@ static void sunxi_hdmi_mode_set(const struct ctfb_res_modes *mode,
/* Write clear interrupt status bits */
writel(SUNXI_HDMI_IRQ_STATUS_BITS, &hdmi->irq);

- if (sunxi_display.monitor == sunxi_monitor_hdmi)
+ if (monitor == sunxi_monitor_hdmi)
sunxi_hdmi_setup_info_frames(mode);

/* Set input sync enable */
@@ -789,7 +804,7 @@ static void sunxi_hdmi_enable(void)

#if defined CONFIG_VIDEO_VGA || defined CONFIG_VIDEO_COMPOSITE

-static void sunxi_tvencoder_mode_set(void)
+static void sunxi_tvencoder_mode_set(enum sunxi_monitor monitor)
{
struct sunxi_ccm_reg * const ccm =
(struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
@@ -801,7 +816,7 @@ static void sunxi_tvencoder_mode_set(void)
/* Clock on */
setbits_le32(&ccm->ahb_gate1, 1 << AHB_GATE_OFFSET_TVE0);

- switch (sunxi_display.monitor) {
+ switch (monitor) {
case sunxi_monitor_vga:
tvencoder_mode_set(tve, tve_mode_vga);
break;
@@ -896,26 +911,28 @@ static void sunxi_engines_init(void)
sunxi_drc_init();
}

-static void sunxi_mode_set(const struct ctfb_res_modes *mode,
+static void sunxi_mode_set(struct sunxi_display *sunxi_display,
+ const struct ctfb_res_modes *mode,
unsigned int address)
{
+ enum sunxi_monitor monitor = sunxi_display->monitor;
int __maybe_unused clk_div, clk_double;
struct sunxi_lcdc_reg * const lcdc =
(struct sunxi_lcdc_reg *)SUNXI_LCD0_BASE;
struct sunxi_tve_reg * __maybe_unused const tve =
(struct sunxi_tve_reg *)SUNXI_TVE0_BASE;

- switch (sunxi_display.monitor) {
+ switch (sunxi_display->monitor) {
case sunxi_monitor_none:
break;
case sunxi_monitor_dvi:
case sunxi_monitor_hdmi:
#ifdef CONFIG_VIDEO_HDMI
- sunxi_composer_mode_set(mode, address);
- sunxi_lcdc_tcon1_mode_set(mode, &clk_div, &clk_double, 0);
- sunxi_hdmi_mode_set(mode, clk_div, clk_double);
+ sunxi_composer_mode_set(mode, address, monitor);
+ sunxi_lcdc_tcon1_mode_set(mode, &clk_div, &clk_double, 0, monitor);
+ sunxi_hdmi_mode_set(mode, clk_div, clk_double, monitor);
sunxi_composer_enable();
- lcdc_enable(lcdc, sunxi_display.depth);
+ lcdc_enable(lcdc, sunxi_display->depth);
sunxi_hdmi_enable();
#endif
break;
@@ -930,7 +947,7 @@ static void sunxi_mode_set(const struct ctfb_res_modes *mode,
axp_set_eldo(3, 1800);
anx9804_init(CONFIG_VIDEO_LCD_I2C_BUS, 4,
ANX9804_DATA_RATE_1620M,
- sunxi_display.depth);
+ sunxi_display->depth);
}
if (IS_ENABLED(CONFIG_VIDEO_LCD_HITACHI_TX18D42VM)) {
mdelay(50); /* Wait for lcd controller power on */
@@ -942,10 +959,10 @@ static void sunxi_mode_set(const struct ctfb_res_modes *mode,
i2c_reg_write(0x5c, 0x04, 0x42); /* Turn on the LCD */
i2c_set_bus_num(orig_i2c_bus);
}
- sunxi_composer_mode_set(mode, address);
- sunxi_lcdc_tcon0_mode_set(mode, false);
+ sunxi_composer_mode_set(mode, address, monitor);
+ sunxi_lcdc_tcon0_mode_set(sunxi_display, mode, false);
sunxi_composer_enable();
- lcdc_enable(lcdc, sunxi_display.depth);
+ lcdc_enable(lcdc, sunxi_display->depth);
#ifdef CONFIG_VIDEO_LCD_SSD2828
sunxi_ssd2828_init(mode);
#endif
@@ -953,17 +970,17 @@ static void sunxi_mode_set(const struct ctfb_res_modes *mode,
break;
case sunxi_monitor_vga:
#ifdef CONFIG_VIDEO_VGA
- sunxi_composer_mode_set(mode, address);
- sunxi_lcdc_tcon1_mode_set(mode, &clk_div, &clk_double, 1);
- sunxi_tvencoder_mode_set();
+ sunxi_composer_mode_set(mode, address, monitor);
+ sunxi_lcdc_tcon1_mode_set(mode, &clk_div, &clk_double, 1, monitor);
+ sunxi_tvencoder_mode_set(monitor);
sunxi_composer_enable();
- lcdc_enable(lcdc, sunxi_display.depth);
+ lcdc_enable(lcdc, sunxi_display->depth);
tvencoder_enable(tve);
#elif defined CONFIG_VIDEO_VGA_VIA_LCD
- sunxi_composer_mode_set(mode, address);
- sunxi_lcdc_tcon0_mode_set(mode, true);
+ sunxi_composer_mode_set(mode, address, monitor);
+ sunxi_lcdc_tcon0_mode_set(sunxi_display, mode, true);
sunxi_composer_enable();
- lcdc_enable(lcdc, sunxi_display.depth);
+ lcdc_enable(lcdc, sunxi_display->depth);
sunxi_vga_external_dac_enable();
#endif
break;
@@ -972,11 +989,11 @@ static void sunxi_mode_set(const struct ctfb_res_modes *mode,
case sunxi_monitor_composite_pal_m:
case sunxi_monitor_composite_pal_nc:
#ifdef CONFIG_VIDEO_COMPOSITE
- sunxi_composer_mode_set(mode, address);
- sunxi_lcdc_tcon1_mode_set(mode, &clk_div, &clk_double, 0);
- sunxi_tvencoder_mode_set();
+ sunxi_composer_mode_set(mode, address, monitor);
+ sunxi_lcdc_tcon1_mode_set(mode, &clk_div, &clk_double, 0, monitor);
+ sunxi_tvencoder_mode_set(monitor);
sunxi_composer_enable();
- lcdc_enable(lcdc, sunxi_display.depth);
+ lcdc_enable(lcdc, sunxi_display->depth);
tvencoder_enable(tve);
#endif
break;
@@ -999,11 +1016,6 @@ static const char *sunxi_get_mon_desc(enum sunxi_monitor monitor)
}
}

-ulong board_get_usable_ram_top(ulong total_size)
-{
- return gd->ram_top - CONFIG_SUNXI_MAX_FB_SIZE;
-}
-
static bool sunxi_has_hdmi(void)
{
#ifdef CONFIG_VIDEO_HDMI
@@ -1052,9 +1064,11 @@ static enum sunxi_monitor sunxi_get_default_mon(bool allow_hdmi)
return sunxi_monitor_none;
}

-void *video_hw_init(void)
+static int sunxi_de_probe(struct udevice *dev)
{
- static GraphicDevice *graphic_device = &sunxi_display.graphic_device;
+ struct video_priv *uc_priv = dev_get_uclass_priv(dev);
+ struct video_uc_platdata *plat = dev_get_uclass_platdata(dev);
+ struct sunxi_display *sunxi_display = dev_get_priv(dev);
const struct ctfb_res_modes *mode;
struct ctfb_res_modes custom;
const char *options;
@@ -1067,10 +1081,8 @@ void *video_hw_init(void)
char mon[16];
char *lcd_mode = CONFIG_VIDEO_LCD_MODE;

- memset(&sunxi_display, 0, sizeof(struct sunxi_display));
-
video_get_ctfb_res_modes(RES_MODE_1024x768, 24, &mode,
- &sunxi_display.depth, &options);
+ &sunxi_display->depth, &options);
#ifdef CONFIG_VIDEO_HDMI
hpd = video_get_option_int(options, "hpd", 1);
hpd_delay = video_get_option_int(options, "hpd_delay", 500);
@@ -1078,35 +1090,35 @@ void *video_hw_init(void)
#endif
overscan_x = video_get_option_int(options, "overscan_x", -1);
overscan_y = video_get_option_int(options, "overscan_y", -1);
- sunxi_display.monitor = sunxi_get_default_mon(true);
+ sunxi_display->monitor = sunxi_get_default_mon(true);
video_get_option_string(options, "monitor", mon, sizeof(mon),
- sunxi_get_mon_desc(sunxi_display.monitor));
+ sunxi_get_mon_desc(sunxi_display->monitor));
for (i = 0; i <= SUNXI_MONITOR_LAST; i++) {
if (strcmp(mon, sunxi_get_mon_desc(i)) == 0) {
- sunxi_display.monitor = i;
+ sunxi_display->monitor = i;
break;
}
}
if (i > SUNXI_MONITOR_LAST)
printf("Unknown monitor: '%s', falling back to '%s'\n",
- mon, sunxi_get_mon_desc(sunxi_display.monitor));
+ mon, sunxi_get_mon_desc(sunxi_display->monitor));

#ifdef CONFIG_VIDEO_HDMI
/* If HDMI/DVI is selected do HPD & EDID, and handle fallback */
- if (sunxi_display.monitor == sunxi_monitor_dvi ||
- sunxi_display.monitor == sunxi_monitor_hdmi) {
+ if (sunxi_display->monitor == sunxi_monitor_dvi ||
+ sunxi_display->monitor == sunxi_monitor_hdmi) {
/* Always call hdp_detect, as it also enables clocks, etc. */
hdmi_present = (sunxi_hdmi_hpd_detect(hpd_delay) == 1);
if (hdmi_present && edid) {
printf("HDMI connected: ");
- if (sunxi_hdmi_edid_get_mode(&custom, true) == 0)
+ if (sunxi_hdmi_edid_get_mode(sunxi_display, &custom, true) == 0)
mode = &custom;
else
hdmi_present = false;
}
/* Fall back to EDID in case HPD failed */
if (edid && !hdmi_present) {
- if (sunxi_hdmi_edid_get_mode(&custom, false) == 0) {
+ if (sunxi_hdmi_edid_get_mode(sunxi_display, &custom, false) == 0) {
mode = &custom;
hdmi_present = true;
}
@@ -1114,38 +1126,39 @@ void *video_hw_init(void)
/* Shut down when display was not found */
if ((hpd || edid) && !hdmi_present) {
sunxi_hdmi_shutdown();
- sunxi_display.monitor = sunxi_get_default_mon(false);
+ sunxi_display->monitor = sunxi_get_default_mon(false);
} /* else continue with hdmi/dvi without a cable connected */
}
#endif

- switch (sunxi_display.monitor) {
+ switch (sunxi_display->monitor) {
case sunxi_monitor_none:
- return NULL;
+ printf("Unknown monitor\n");
+ return -EINVAL;
case sunxi_monitor_dvi:
case sunxi_monitor_hdmi:
if (!sunxi_has_hdmi()) {
printf("HDMI/DVI not supported on this board\n");
- sunxi_display.monitor = sunxi_monitor_none;
- return NULL;
+ sunxi_display->monitor = sunxi_monitor_none;
+ return -EINVAL;
}
break;
case sunxi_monitor_lcd:
if (!sunxi_has_lcd()) {
printf("LCD not supported on this board\n");
- sunxi_display.monitor = sunxi_monitor_none;
- return NULL;
+ sunxi_display->monitor = sunxi_monitor_none;
+ return -EINVAL;
}
- sunxi_display.depth = video_get_params(&custom, lcd_mode);
+ sunxi_display->depth = video_get_params(&custom, lcd_mode);
mode = &custom;
break;
case sunxi_monitor_vga:
if (!sunxi_has_vga()) {
printf("VGA not supported on this board\n");
- sunxi_display.monitor = sunxi_monitor_none;
- return NULL;
+ sunxi_display->monitor = sunxi_monitor_none;
+ return -EINVAL;
}
- sunxi_display.depth = 18;
+ sunxi_display->depth = 18;
break;
case sunxi_monitor_composite_pal:
case sunxi_monitor_composite_ntsc:
@@ -1153,85 +1166,103 @@ void *video_hw_init(void)
case sunxi_monitor_composite_pal_nc:
if (!sunxi_has_composite()) {
printf("Composite video not supported on this board\n");
- sunxi_display.monitor = sunxi_monitor_none;
- return NULL;
+ sunxi_display->monitor = sunxi_monitor_none;
+ return -EINVAL;
}
- if (sunxi_display.monitor == sunxi_monitor_composite_pal ||
- sunxi_display.monitor == sunxi_monitor_composite_pal_nc)
+ if (sunxi_display->monitor == sunxi_monitor_composite_pal ||
+ sunxi_display->monitor == sunxi_monitor_composite_pal_nc)
mode = &composite_video_modes[0];
else
mode = &composite_video_modes[1];
- sunxi_display.depth = 24;
+ sunxi_display->depth = 24;
break;
}

/* Yes these defaults are quite high, overscan on composite sucks... */
if (overscan_x == -1)
- overscan_x = sunxi_is_composite() ? 32 : 0;
+ overscan_x = sunxi_is_composite(sunxi_display->monitor) ? 32 : 0;
if (overscan_y == -1)
- overscan_y = sunxi_is_composite() ? 20 : 0;
+ overscan_y = sunxi_is_composite(sunxi_display->monitor) ? 20 : 0;

- sunxi_display.fb_size =
- (mode->xres * mode->yres * 4 + 0xfff) & ~0xfff;
+ sunxi_display->fb_size = plat->size;
overscan_offset = (overscan_y * mode->xres + overscan_x) * 4;
/* We want to keep the fb_base for simplefb page aligned, where as
* the sunxi dma engines will happily accept an unaligned address. */
if (overscan_offset)
- sunxi_display.fb_size += 0x1000;
-
- if (sunxi_display.fb_size > CONFIG_SUNXI_MAX_FB_SIZE) {
- printf("Error need %dkB for fb, but only %dkB is reserved\n",
- sunxi_display.fb_size >> 10,
- CONFIG_SUNXI_MAX_FB_SIZE >> 10);
- return NULL;
- }
+ sunxi_display->fb_size += 0x1000;

printf("Setting up a %dx%d%s %s console (overscan %dx%d)\n",
mode->xres, mode->yres,
(mode->vmode == FB_VMODE_INTERLACED) ? "i" : "",
- sunxi_get_mon_desc(sunxi_display.monitor),
+ sunxi_get_mon_desc(sunxi_display->monitor),
overscan_x, overscan_y);

- gd->fb_base = gd->bd->bi_dram[0].start +
- gd->bd->bi_dram[0].size - sunxi_display.fb_size;
+ sunxi_display->fb_addr = plat->base;
sunxi_engines_init();

#ifdef CONFIG_EFI_LOADER
- efi_add_memory_map(gd->fb_base, sunxi_display.fb_size,
+ efi_add_memory_map(sunxi_display->fb_addr, sunxi_display->fb_size,
EFI_RESERVED_MEMORY_TYPE);
#endif

- fb_dma_addr = gd->fb_base - CONFIG_SYS_SDRAM_BASE;
- sunxi_display.fb_addr = gd->fb_base;
+ fb_dma_addr = sunxi_display->fb_addr - CONFIG_SYS_SDRAM_BASE;
if (overscan_offset) {
fb_dma_addr += 0x1000 - (overscan_offset & 0xfff);
- sunxi_display.fb_addr += (overscan_offset + 0xfff) & ~0xfff;
- memset((void *)gd->fb_base, 0, sunxi_display.fb_size);
- flush_cache(gd->fb_base, sunxi_display.fb_size);
+ sunxi_display->fb_addr += (overscan_offset + 0xfff) & ~0xfff;
+ memset((void *)sunxi_display->fb_addr, 0, sunxi_display->fb_size);
+ flush_cache(sunxi_display->fb_addr, sunxi_display->fb_size);
}
- sunxi_mode_set(mode, fb_dma_addr);
+ sunxi_mode_set(sunxi_display, mode, fb_dma_addr);

/*
* These are the only members of this structure that are used. All the
* others are driver specific. The pitch is stored in plnSizeX.
*/
- graphic_device->frameAdrs = sunxi_display.fb_addr;
- graphic_device->gdfIndex = GDF_32BIT_X888RGB;
- graphic_device->gdfBytesPP = 4;
- graphic_device->winSizeX = mode->xres - 2 * overscan_x;
- graphic_device->winSizeY = mode->yres - 2 * overscan_y;
- graphic_device->plnSizeX = mode->xres * graphic_device->gdfBytesPP;
-
- return graphic_device;
+ uc_priv->bpix = VIDEO_BPP32;
+ uc_priv->xsize = mode->xres;
+ uc_priv->ysize = mode->yres;
+
+ video_set_flush_dcache(dev, 1);
+
+ return 0;
+}
+
+static int sunxi_de_bind(struct udevice *dev)
+{
+ struct video_uc_platdata *plat = dev_get_uclass_platdata(dev);
+
+ plat->size = LCD_MAX_WIDTH * LCD_MAX_HEIGHT *
+ (1 << LCD_MAX_LOG2_BPP) / 8;
+
+ return 0;
}

+static const struct video_ops sunxi_de_ops = {
+};
+
+U_BOOT_DRIVER(sunxi_de) = {
+ .name = "sunxi_de",
+ .id = UCLASS_VIDEO,
+ .ops = &sunxi_de_ops,
+ .bind = sunxi_de_bind,
+ .probe = sunxi_de_probe,
+ .priv_auto_alloc_size = sizeof(struct sunxi_display),
+ .flags = DM_FLAG_PRE_RELOC,
+};
+
+U_BOOT_DEVICE(sunxi_de) = {
+ .name = "sunxi_de"
+};
+
/*
* Simplefb support.
*/
#if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_VIDEO_DT_SIMPLEFB)
int sunxi_simplefb_setup(void *blob)
{
- static GraphicDevice *graphic_device = &sunxi_display.graphic_device;
+ struct sunxi_display *sunxi_display;
+ struct video_priv *uc_priv;
+ struct udevice *de;
int offset, ret;
u64 start, size;
const char *pipeline = NULL;
@@ -1242,7 +1273,19 @@ int sunxi_simplefb_setup(void *blob)
#define PIPELINE_PREFIX
#endif

- switch (sunxi_display.monitor) {
+ ret = uclass_find_device_by_name(UCLASS_VIDEO, "sunxi_de", &de);
+ if (ret) {
+ printf("DE not present\n");
+ return 0;
+ } else if (!device_active(de)) {
+ printf("DE is present but not probed\n");
+ return 0;
+ }
+
+ uc_priv = dev_get_uclass_priv(de);
+ sunxi_display = dev_get_priv(de);
+
+ switch (sunxi_display->monitor) {
case sunxi_monitor_none:
return 0;
case sunxi_monitor_dvi:
@@ -1280,16 +1323,17 @@ int sunxi_simplefb_setup(void *blob)
* linux/arch/arm/mm/ioremap.c around line 301.
*/
start = gd->bd->bi_dram[0].start;
- size = gd->bd->bi_dram[0].size - sunxi_display.fb_size;
+ size = gd->bd->bi_dram[0].size - sunxi_display->fb_size;
ret = fdt_fixup_memory_banks(blob, &start, &size, 1);
if (ret) {
eprintf("Cannot setup simplefb: Error reserving memory\n");
return ret;
}

- ret = fdt_setup_simplefb_node(blob, offset, sunxi_display.fb_addr,
- graphic_device->winSizeX, graphic_device->winSizeY,
- graphic_device->plnSizeX, "x8r8g8b8");
+ ret = fdt_setup_simplefb_node(blob, offset, sunxi_display->fb_addr,
+ uc_priv->xsize, uc_priv->ysize,
+ VNBYTES(uc_priv->bpix) * uc_priv->xsize,
+ "x8r8g8b8");
if (ret)
eprintf("Cannot setup simplefb: Error setting properties\n");

diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
index 308d7a42aa..affedda46c 100644
--- a/include/configs/sunxi-common.h
+++ b/include/configs/sunxi-common.h
@@ -253,23 +253,6 @@ extern int soft_i2c_gpio_scl;
#endif
#endif /* ifdef CONFIG_REQUIRE_SERIAL_CONSOLE */

-#ifdef CONFIG_VIDEO_SUNXI
-/*
- * The amount of RAM to keep free at the top of RAM when relocating u-boot,
- * to use as framebuffer. This must be a multiple of 4096.
- */
-#define CONFIG_SUNXI_MAX_FB_SIZE (16 << 20)
-
-#define CONFIG_VIDEO_LOGO
-#define CONFIG_VIDEO_STD_TIMINGS
-#define CONFIG_I2C_EDID
-#define VIDEO_LINE_LEN (pGD->plnSizeX)
-
-/* allow both serial and cfb console. */
-/* stop x86 thinking in cfbconsole from trying to init a pc keyboard */
-
-#endif /* CONFIG_VIDEO_SUNXI */
-
#if CONFIG_IS_ENABLED(CMD_BMP)
# define CONFIG_VIDEO_BMP_RLE8
# define CONFIG_SPLASH_SCREEN
diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt
index f6bf6f2474..30a101638e 100644
--- a/scripts/config_whitelist.txt
+++ b/scripts/config_whitelist.txt
@@ -1724,7 +1724,6 @@ CONFIG_STV0991
CONFIG_STV0991_HZ
CONFIG_STV0991_HZ_CLOCK
CONFIG_ST_SMI
-CONFIG_SUNXI_MAX_FB_SIZE
CONFIG_SXNI855T
CONFIG_SYSFLAGS_ADDR
CONFIG_SYSFS
--
2.25.1

Tom Rini

unread,
Jun 18, 2020, 9:04:57 AM6/18/20
to Maxime Ripard, Jagan Teki, Anatolij Gustschin, u-b...@lists.denx.de, Hans de Goede, Zoltan Herpai, Aleksei Mamlin, Priit Laes, Paul Kocialkowski, Chen-Yu Tsai, Phil Han, Siarhei Siamashka, Peter Korsgaard, Stefan Mavrodiev, Icenowy Zheng, Quentin Schulz, FUKAUMI Naoki, Marcus Cooper, Stefan Mavrodiev, Iain Paton, Olliver Schinagl, Ian Campbell, Stefan Roese, Jelle de Jong, Adam Sampson, linux...@googlegroups.com, linux-...@amarulasolutions.com
On Thu, Jun 18, 2020 at 09:16:30AM +0200, Maxime Ripard wrote:
> Hi,
>
> On Thu, Jun 18, 2020 at 01:54:35AM +0530, Jagan Teki wrote:
> > Add sunxi logo which would be used for splash screen support.
> >
> > The original images were the crapped version from linux-sunxi.org
> > and generated using below step
> >
> > $ convert sunxi.jpg -type Palette -colors 224 -depth 8 \
> > -compress none -verbose BMP3:tools/logos/sunxi.bmp
> >
> > Signed-off-by: Jagan Teki <ja...@amarulasolutions.com>
>
> I'm not entirely sure what the benefit of that is to be honest.
>
> U-boot has a logo, why not use it?

I don't have strong feelings here. Typically, it's a vendor that wants
their logo used rather than the community logo and not the community
bringing in the vendors logo for them.

--
Tom
signature.asc

Jagan Teki

unread,
Jun 18, 2020, 12:07:25 PM6/18/20
to Maxime Ripard, Anatolij Gustschin, U-Boot-Denx, Hans de Goede, Zoltan Herpai, Aleksei Mamlin, Priit Laes, Paul Kocialkowski, Chen-Yu Tsai, Phil Han, Siarhei Siamashka, Peter Korsgaard, Stefan Mavrodiev, Icenowy Zheng, Quentin Schulz, FUKAUMI Naoki, Marcus Cooper, Stefan Mavrodiev, Iain Paton, Olliver Schinagl, Ian Campbell, Stefan Roese, Jelle de Jong, Adam Sampson, Tom Rini, linux-sunxi, linux-amarula
On Thu, Jun 18, 2020 at 12:54 PM Maxime Ripard <max...@cerno.tech> wrote:
> Why is that an enum? Those three values don't have any relationship with
> each other.

Not sure I understand your question. These are maximum resolution
followed by maximum bpp supporting. based on these the fbbuffer
allocation happens, please see sunxi_de_bind on this patch.

>
> > enum sunxi_monitor {
> > sunxi_monitor_none,
> > sunxi_monitor_dvi,
> > @@ -59,12 +70,11 @@ enum sunxi_monitor {
> > #define SUNXI_MONITOR_LAST sunxi_monitor_composite_pal_nc
> >
> > struct sunxi_display {
> > - GraphicDevice graphic_device;
> > enum sunxi_monitor monitor;
> > unsigned int depth;
> > unsigned int fb_addr;
> > unsigned int fb_size;
> > -} sunxi_display;
> > +};
>
> This looks unrelated?
> I couldn't find how you're allocating and reserving the video buffer now
> for simplefb to use later on.

Based on maximum supporting resolutions and bpp as explained above and
similar like what sunxi_de2 and other platforms like rockchip. via
plat->size.
> This is new. You should explain in a separate patch why the flush_cache
> above isn't enough.

This is new and but required when for DM_VIDEO conversion.
video-uclass has a common way to flush video via video_sync so the
driver has to trigger this flush and without this, the vidconsole
shows inconsistent characters.

Jagan.

Michael Nazzareno Trimarchi

unread,
Jun 18, 2020, 1:14:12 PM6/18/20
to Jagan Teki, Maxime Ripard, Anatolij Gustschin, U-Boot-Denx, Hans de Goede, Zoltan Herpai, Aleksei Mamlin, Priit Laes, Paul Kocialkowski, Chen-Yu Tsai, Phil Han, Siarhei Siamashka, Peter Korsgaard, Stefan Mavrodiev, Icenowy Zheng, Quentin Schulz, FUKAUMI Naoki, Marcus Cooper, Stefan Mavrodiev, Iain Paton, Olliver Schinagl, Ian Campbell, Stefan Roese, Jelle de Jong, Adam Sampson, Tom Rini, linux-sunxi, linux-amarula
Hi
DM_VIDEO, take from the relocation - VIDEO_SIZE if I remember based on MAX video
size. Then there is always a logic to inject in the simple_framebuffer
dts the information for
reserved memory. The platform always defines MAX_SIZE of the video. so
HDMI resolutions
that does not fit the size are not handled. Rockchip is not completed
on this implementation, I have
sent a patch some time ago but I was struggling to have a working
persistent framebuffer

Michael
--
| Michael Nazzareno Trimarchi Amarula Solutions BV |
| COO - Founder Cruquiuskade 47 |
| +31(0)851119172 Amsterdam 1018 AM NL |
| [`as] http://www.amarulasolutions.com |

Andre Przywara

unread,
Feb 4, 2021, 5:31:38 PM2/4/21
to Maxime Ripard, Jagan Teki, Anatolij Gustschin, U-Boot-Denx, Hans de Goede, Zoltan Herpai, Aleksei Mamlin, Priit Laes, Paul Kocialkowski, Chen-Yu Tsai, Phil Han, Siarhei Siamashka, Peter Korsgaard, Stefan Mavrodiev, Icenowy Zheng, Quentin Schulz, FUKAUMI Naoki, Marcus Cooper, Stefan Mavrodiev, Iain Paton, Olliver Schinagl, Ian Campbell, Stefan Roese, Jelle de Jong, Adam Sampson, Tom Rini, linux-sunxi, linux-amarula
On Fri, 19 Jun 2020 09:30:22 +0200
Maxime Ripard <max...@cerno.tech> wrote:

Hi,

I have picked up this patch, rebased, updated and fixed some parts.

I will send a v3 ASAP, so we can continue the discussion on this.

I am replying here to some of the outstanding comments, since this has
the context:
> An enum is used for variables that can hold multiple values. There's no
> relationship between those values, you cannot use the BPP in place of
> the width there for example, it doesn't make any sense. So you must not
> use an enum.

I agree that an enum does not make sense here. That seems to be
copied from sunxi_de2.c, which has the same code ;-)
My guess is this stems from some misunderstood "use enums instead of
#define!" recommendation. I replaced it with old-fashioned #defines.

>
> > > > -ulong board_get_usable_ram_top(ulong total_size)
> > > > -{
> > > > - return gd->ram_top - CONFIG_SUNXI_MAX_FB_SIZE;
> > > > -}
> > > > -
> > >
> > > I couldn't find how you're allocating and reserving the video buffer now
> > > for simplefb to use later on.
> >
> > Based on maximum supporting resolutions and bpp as explained above and
> > similar like what sunxi_de2 and other platforms like rockchip. via
> > plat->size.
>
> It really doesn't explain how you're allocating and reserving it for
> simplefb though, merely how much memory you're allocating.
>
> Let me rephrase this. simplefb will run in Linux based on an address
> that is passed from the bootloader to Linux through the device tree. How
> do you make sure that Linux will not reuse that buffer for something
> else once it's been booted?
>
> The previous code was doing that by removing enough space from the total
> memory available, so Linux could run only on the total amount of RAM
> minus the size of the framebuffer. You removed that, so how does it work
> now?

So the former code lowered U-Boot's perception of gd->ram_top, but
sunxi-de2 doesn't do this either. I don't think this on its own is a
real problem.
What both sunxi-de2 and this patch do is to patch the /memory node in
the DT to exclude the framebuffer region, at the same time when
patching in the framebuffer details into the chosen node (in the last
function of this patch, not in this email anymore).

There *is* a bug in this patch that creates a small overlap, which
makes Linux crash. That's easily fixed, though:

start = gd->bd->bi_dram[0].start;
- size = gd->bd->bi_dram[0].size - sunxi_display->fb_size;
+ size = sunxi_display->fb_addr - start;
ret = fdt_fixup_memory_banks(blob, &start, &size, 1);

Maxime, does that answer your concerns? I tested this (fixed) patch with
simplefb, and it works: the /memory node ends 32MB before the end of
DRAM, and the framebuffer works in Linux.

> And if you're changing that somehow, at the very least, it should be
> either in a separate patch or mentionned in the commit log.
> I still believe this is redundant with the flush_cache above.

So this video_set_flush_dcache() does not *do* an actual cache_clean, it
merely enables regular cache cleans in video-uclass.c:video_sync().
This replaces the automatic determination of
CONFIG_VIDEO's cfb_do_flush_cache in cfb_console.c, with an explicit
request.
The initial cache clean of the framebuffer above is independent of this.
sunxi_de2 does this video_set_flush_dcache() call as well.

Cheers,
Andre

Andre Przywara

unread,
Feb 4, 2021, 8:08:49 PM2/4/21
to Jagan Teki, Anatolij Gustschin, u-b...@lists.denx.de, Maxime Ripard, Simon Glass, Tom Rini, Jernej Skrabec, Icenowy Zheng, Priit Laes, Chen-Yu Tsai, linux...@googlegroups.com
From: Jagan Teki <ja...@amarulasolutions.com>

DM_VIDEO migration deadline is already expired, but around
80 Allwinner boards are still using video in a legacy way.

===================== WARNING ======================
This board does not use CONFIG_DM_VIDEO Please update
the board to use CONFIG_DM_VIDEO before the v2019.07 release.
Failure to update by the deadline may result in board removal.
See doc/driver-model/migration.rst for more info.
====================================================

Convert the legacy video driver over to the DM_VIDEO framework. This is
a minimal conversion: it doesn't use the DT for finding its resources,
nor does it use DM clocks or DM devices for the outputs (LCD, HDMI, CVBS).

Tested in Bananapi M1+ Plus 1920x1200 HDMI out. (Jagan)

Signed-off-by: Jagan Teki <ja...@amarulasolutions.com>
[Andre: rebase and smaller fixes]
Signed-off-by: Andre Przywara <andre.p...@arm.com>
---
Hi,

I picked this one up to get rid of the warnings. I dropped the BMP
support for now (v2 1/3 and v2 2/3), I need to have a closer look, as
I am not convinced this was the right solution.

Cheers,
Andre

Changelog v2 .. v3:
- rebase against master, fixing up renamed variables and structs
- replace enum with #define
- remove BMP from Kconfig
- fix memory node size calculation in simplefb setup

arch/arm/mach-sunxi/Kconfig | 9 +-
drivers/video/sunxi/sunxi_display.c | 262 ++++++++++++++++------------
include/configs/sunxi-common.h | 17 --
scripts/config_whitelist.txt | 1 -
4 files changed, 157 insertions(+), 132 deletions(-)

diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
index 0135575ca1e..a29d11505aa 100644
--- a/arch/arm/mach-sunxi/Kconfig
+++ b/arch/arm/mach-sunxi/Kconfig
@@ -816,13 +816,14 @@ config VIDEO_SUNXI
depends on !MACH_SUN9I
depends on !MACH_SUN50I
depends on !SUN50I_GEN_H6
- select VIDEO
+ select DM_VIDEO
+ select DISPLAY
imply VIDEO_DT_SIMPLEFB
default y
---help---
- Say Y here to add support for using a cfb console on the HDMI, LCD
- or VGA output found on most sunxi devices. See doc/README.video for
- info on how to select the video output and mode.
+ Say Y here to add support for using a graphical console on the HDMI,
+ LCD or VGA output found on older sunxi devices. This will also provide
+ a simple_framebuffer device for Linux.

config VIDEO_HDMI
bool "HDMI output support"
diff --git a/drivers/video/sunxi/sunxi_display.c b/drivers/video/sunxi/sunxi_display.c
index f52aba4d21c..61498d1642f 100644
--- a/drivers/video/sunxi/sunxi_display.c
+++ b/drivers/video/sunxi/sunxi_display.c
@@ -7,6 +7,8 @@
*/

#include <common.h>
+#include <display.h>
+#include <dm.h>
#include <cpu_func.h>
#include <efi_loader.h>
#include <init.h>
@@ -28,7 +30,9 @@
#include <fdt_support.h>
#include <i2c.h>
#include <malloc.h>
+#include <video.h>
#include <video_fb.h>
+#include <dm/uclass-internal.h>
#include "../videomodes.h"
#include "../anx9804.h"
#include "../hitachi_tx18d42vm_lcd.h"
@@ -45,6 +49,11 @@

DECLARE_GLOBAL_DATA_PTR;

+/* Maximum LCD size we support */
+#define LCD_MAX_WIDTH 3840
+#define LCD_MAX_HEIGHT 2160
+#define LCD_MAX_LOG2_BPP VIDEO_BPP32
+
enum sunxi_monitor {
sunxi_monitor_none,
sunxi_monitor_dvi,
@@ -59,12 +68,11 @@ enum sunxi_monitor {
#define SUNXI_MONITOR_LAST sunxi_monitor_composite_pal_nc

struct sunxi_display {
- GraphicDevice graphic_device;
enum sunxi_monitor monitor;
unsigned int depth;
unsigned int fb_addr;
unsigned int fb_size;
-} sunxi_display;
+};

const struct ctfb_res_modes composite_video_modes[2] = {
/* x y hz pixclk ps/kHz le ri up lo hs vs s vmode */
@@ -214,7 +222,8 @@ static int sunxi_hdmi_edid_get_block(int block, u8 *buf)
return r;
}

-static int sunxi_hdmi_edid_get_mode(struct ctfb_res_modes *mode,
+static int sunxi_hdmi_edid_get_mode(struct sunxi_display *sunxi_display,
+ struct ctfb_res_modes *mode,
bool verbose_mode)
{
struct edid1_info edid1;
@@ -291,14 +300,14 @@ static int sunxi_hdmi_edid_get_mode(struct ctfb_res_modes *mode,
}

/* Check for basic audio support, if found enable hdmi output */
- sunxi_display.monitor = sunxi_monitor_dvi;
+ sunxi_display->monitor = sunxi_monitor_dvi;
for (i = 0; i < ext_blocks; i++) {
if (cea681[i].extension_tag != EDID_CEA861_EXTENSION_TAG ||
cea681[i].revision < 2)
continue;

if (EDID_CEA861_SUPPORTS_BASIC_AUDIO(cea681[i]))
- sunxi_display.monitor = sunxi_monitor_hdmi;
+ sunxi_display->monitor = sunxi_monitor_hdmi;
}

return 0;
@@ -414,9 +423,9 @@ static void sunxi_frontend_mode_set(const struct ctfb_res_modes *mode,
static void sunxi_frontend_enable(void) {}
#endif

-static bool sunxi_is_composite(void)
+static bool sunxi_is_composite(enum sunxi_monitor monitor)
{
- switch (sunxi_display.monitor) {
+ switch (monitor) {
case sunxi_monitor_none:
case sunxi_monitor_dvi:
case sunxi_monitor_hdmi:
@@ -473,7 +482,8 @@ static const u32 sunxi_rgb2yuv_coef[12] = {
};

static void sunxi_composer_mode_set(const struct ctfb_res_modes *mode,
- unsigned int address)
+ unsigned int address,
+ enum sunxi_monitor monitor)
{
struct sunxi_de_be_reg * const de_be =
(struct sunxi_de_be_reg *)SUNXI_DE_BE0_BASE;
@@ -502,7 +512,7 @@ static void sunxi_composer_mode_set(const struct ctfb_res_modes *mode,
#endif
SUNXI_DE_BE_MODE_INTERLACE_ENABLE);

- if (sunxi_is_composite()) {
+ if (sunxi_is_composite(monitor)) {
writel(SUNXI_DE_BE_OUTPUT_COLOR_CTRL_ENABLE,
&de_be->output_color_ctrl);
for (i = 0; i < 12; i++)
@@ -616,7 +626,8 @@ static void sunxi_lcdc_backlight_enable(void)
gpio_direction_output(pin, PWM_ON);
}

-static void sunxi_lcdc_tcon0_mode_set(const struct ctfb_res_modes *mode,
+static void sunxi_lcdc_tcon0_mode_set(struct sunxi_display *sunxi_display,
+ const struct ctfb_res_modes *mode,
bool for_ext_vga_dac)
{
struct sunxi_lcdc_reg * const lcdc =
@@ -643,17 +654,18 @@ static void sunxi_lcdc_tcon0_mode_set(const struct ctfb_res_modes *mode,
}

lcdc_pll_set(ccm, 0, mode->pixclock_khz, &clk_div, &clk_double,
- sunxi_is_composite());
+ sunxi_is_composite(sunxi_display->monitor));

video_ctfb_mode_to_display_timing(mode, &timing);
lcdc_tcon0_mode_set(lcdc, &timing, clk_div, for_ext_vga_dac,
- sunxi_display.depth, CONFIG_VIDEO_LCD_DCLK_PHASE);
+ sunxi_display->depth, CONFIG_VIDEO_LCD_DCLK_PHASE);
}

#if defined CONFIG_VIDEO_HDMI || defined CONFIG_VIDEO_VGA || defined CONFIG_VIDEO_COMPOSITE
static void sunxi_lcdc_tcon1_mode_set(const struct ctfb_res_modes *mode,
int *clk_div, int *clk_double,
- bool use_portd_hvsync)
+ bool use_portd_hvsync,
+ enum sunxi_monitor monitor)
{
struct sunxi_lcdc_reg * const lcdc =
(struct sunxi_lcdc_reg *)SUNXI_LCD0_BASE;
@@ -663,7 +675,7 @@ static void sunxi_lcdc_tcon1_mode_set(const struct ctfb_res_modes *mode,

video_ctfb_mode_to_display_timing(mode, &timing);
lcdc_tcon1_mode_set(lcdc, &timing, use_portd_hvsync,
- sunxi_is_composite());
+ sunxi_is_composite(monitor));

if (use_portd_hvsync) {
sunxi_gpio_set_cfgpin(SUNXI_GPD(26), SUNXI_GPD_LCD0);
@@ -671,7 +683,7 @@ static void sunxi_lcdc_tcon1_mode_set(const struct ctfb_res_modes *mode,
}

lcdc_pll_set(ccm, 1, mode->pixclock_khz, clk_div, clk_double,
- sunxi_is_composite());
+ sunxi_is_composite(monitor));
}
#endif /* CONFIG_VIDEO_HDMI || defined CONFIG_VIDEO_VGA || CONFIG_VIDEO_COMPOSITE */

@@ -725,7 +737,8 @@ static void sunxi_hdmi_setup_info_frames(const struct ctfb_res_modes *mode)
}

static void sunxi_hdmi_mode_set(const struct ctfb_res_modes *mode,
- int clk_div, int clk_double)
+ int clk_div, int clk_double,
+ enum sunxi_monitor monitor)
{
struct sunxi_hdmi_reg * const hdmi =
(struct sunxi_hdmi_reg *)SUNXI_HDMI_BASE;
@@ -734,7 +747,7 @@ static void sunxi_hdmi_mode_set(const struct ctfb_res_modes *mode,
/* Write clear interrupt status bits */
writel(SUNXI_HDMI_IRQ_STATUS_BITS, &hdmi->irq);

- if (sunxi_display.monitor == sunxi_monitor_hdmi)
+ if (monitor == sunxi_monitor_hdmi)
sunxi_hdmi_setup_info_frames(mode);

/* Set input sync enable */
@@ -789,7 +802,7 @@ static void sunxi_hdmi_enable(void)

#if defined CONFIG_VIDEO_VGA || defined CONFIG_VIDEO_COMPOSITE

-static void sunxi_tvencoder_mode_set(void)
+static void sunxi_tvencoder_mode_set(enum sunxi_monitor monitor)
{
struct sunxi_ccm_reg * const ccm =
(struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
@@ -801,7 +814,7 @@ static void sunxi_tvencoder_mode_set(void)
/* Clock on */
setbits_le32(&ccm->ahb_gate1, 1 << AHB_GATE_OFFSET_TVE0);

- switch (sunxi_display.monitor) {
+ switch (monitor) {
case sunxi_monitor_vga:
tvencoder_mode_set(tve, tve_mode_vga);
break;
@@ -896,26 +909,28 @@ static void sunxi_engines_init(void)
sunxi_drc_init();
}

-static void sunxi_mode_set(const struct ctfb_res_modes *mode,
+static void sunxi_mode_set(struct sunxi_display *sunxi_display,
+ const struct ctfb_res_modes *mode,
unsigned int address)
{
+ enum sunxi_monitor monitor = sunxi_display->monitor;
int __maybe_unused clk_div, clk_double;
struct sunxi_lcdc_reg * const lcdc =
(struct sunxi_lcdc_reg *)SUNXI_LCD0_BASE;
struct sunxi_tve_reg * __maybe_unused const tve =
(struct sunxi_tve_reg *)SUNXI_TVE0_BASE;

- switch (sunxi_display.monitor) {
+ switch (sunxi_display->monitor) {
case sunxi_monitor_none:
break;
case sunxi_monitor_dvi:
case sunxi_monitor_hdmi:
#ifdef CONFIG_VIDEO_HDMI
- sunxi_composer_mode_set(mode, address);
- sunxi_lcdc_tcon1_mode_set(mode, &clk_div, &clk_double, 0);
- sunxi_hdmi_mode_set(mode, clk_div, clk_double);
+ sunxi_composer_mode_set(mode, address, monitor);
+ sunxi_lcdc_tcon1_mode_set(mode, &clk_div, &clk_double, 0, monitor);
+ sunxi_hdmi_mode_set(mode, clk_div, clk_double, monitor);
sunxi_composer_enable();
- lcdc_enable(lcdc, sunxi_display.depth);
+ lcdc_enable(lcdc, sunxi_display->depth);
sunxi_hdmi_enable();
#endif
break;
@@ -930,7 +945,7 @@ static void sunxi_mode_set(const struct ctfb_res_modes *mode,
axp_set_eldo(3, 1800);
anx9804_init(CONFIG_VIDEO_LCD_I2C_BUS, 4,
ANX9804_DATA_RATE_1620M,
- sunxi_display.depth);
+ sunxi_display->depth);
}
if (IS_ENABLED(CONFIG_VIDEO_LCD_HITACHI_TX18D42VM)) {
mdelay(50); /* Wait for lcd controller power on */
@@ -942,10 +957,10 @@ static void sunxi_mode_set(const struct ctfb_res_modes *mode,
i2c_reg_write(0x5c, 0x04, 0x42); /* Turn on the LCD */
i2c_set_bus_num(orig_i2c_bus);
}
- sunxi_composer_mode_set(mode, address);
- sunxi_lcdc_tcon0_mode_set(mode, false);
+ sunxi_composer_mode_set(mode, address, monitor);
+ sunxi_lcdc_tcon0_mode_set(sunxi_display, mode, false);
sunxi_composer_enable();
- lcdc_enable(lcdc, sunxi_display.depth);
+ lcdc_enable(lcdc, sunxi_display->depth);
#ifdef CONFIG_VIDEO_LCD_SSD2828
sunxi_ssd2828_init(mode);
#endif
@@ -953,17 +968,17 @@ static void sunxi_mode_set(const struct ctfb_res_modes *mode,
break;
case sunxi_monitor_vga:
#ifdef CONFIG_VIDEO_VGA
- sunxi_composer_mode_set(mode, address);
- sunxi_lcdc_tcon1_mode_set(mode, &clk_div, &clk_double, 1);
- sunxi_tvencoder_mode_set();
+ sunxi_composer_mode_set(mode, address, monitor);
+ sunxi_lcdc_tcon1_mode_set(mode, &clk_div, &clk_double, 1, monitor);
+ sunxi_tvencoder_mode_set(monitor);
sunxi_composer_enable();
- lcdc_enable(lcdc, sunxi_display.depth);
+ lcdc_enable(lcdc, sunxi_display->depth);
tvencoder_enable(tve);
#elif defined CONFIG_VIDEO_VGA_VIA_LCD
- sunxi_composer_mode_set(mode, address);
- sunxi_lcdc_tcon0_mode_set(mode, true);
+ sunxi_composer_mode_set(mode, address, monitor);
+ sunxi_lcdc_tcon0_mode_set(sunxi_display, mode, true);
sunxi_composer_enable();
- lcdc_enable(lcdc, sunxi_display.depth);
+ lcdc_enable(lcdc, sunxi_display->depth);
sunxi_vga_external_dac_enable();
#endif
break;
@@ -972,11 +987,11 @@ static void sunxi_mode_set(const struct ctfb_res_modes *mode,
case sunxi_monitor_composite_pal_m:
case sunxi_monitor_composite_pal_nc:
#ifdef CONFIG_VIDEO_COMPOSITE
- sunxi_composer_mode_set(mode, address);
- sunxi_lcdc_tcon1_mode_set(mode, &clk_div, &clk_double, 0);
- sunxi_tvencoder_mode_set();
+ sunxi_composer_mode_set(mode, address, monitor);
+ sunxi_lcdc_tcon1_mode_set(mode, &clk_div, &clk_double, 0, monitor);
+ sunxi_tvencoder_mode_set(monitor);
sunxi_composer_enable();
- lcdc_enable(lcdc, sunxi_display.depth);
+ lcdc_enable(lcdc, sunxi_display->depth);
tvencoder_enable(tve);
#endif
break;
@@ -999,11 +1014,6 @@ static const char *sunxi_get_mon_desc(enum sunxi_monitor monitor)
}
}

-ulong board_get_usable_ram_top(ulong total_size)
-{
- return gd->ram_top - CONFIG_SUNXI_MAX_FB_SIZE;
-}
-
static bool sunxi_has_hdmi(void)
{
#ifdef CONFIG_VIDEO_HDMI
@@ -1052,9 +1062,11 @@ static enum sunxi_monitor sunxi_get_default_mon(bool allow_hdmi)
return sunxi_monitor_none;
}

-void *video_hw_init(void)
+static int sunxi_de_probe(struct udevice *dev)
{
- static GraphicDevice *graphic_device = &sunxi_display.graphic_device;
+ struct video_priv *uc_priv = dev_get_uclass_priv(dev);
+ struct video_uc_plat *plat = dev_get_uclass_plat(dev);
+ struct sunxi_display *sunxi_display = dev_get_priv(dev);
const struct ctfb_res_modes *mode;
struct ctfb_res_modes custom;
const char *options;
@@ -1067,10 +1079,8 @@ void *video_hw_init(void)
char mon[16];
char *lcd_mode = CONFIG_VIDEO_LCD_MODE;

- memset(&sunxi_display, 0, sizeof(struct sunxi_display));
-
video_get_ctfb_res_modes(RES_MODE_1024x768, 24, &mode,
- &sunxi_display.depth, &options);
+ &sunxi_display->depth, &options);
#ifdef CONFIG_VIDEO_HDMI
hpd = video_get_option_int(options, "hpd", 1);
hpd_delay = video_get_option_int(options, "hpd_delay", 500);
@@ -1078,35 +1088,35 @@ void *video_hw_init(void)
@@ -1114,38 +1124,39 @@ void *video_hw_init(void)
@@ -1153,85 +1164,103 @@ void *video_hw_init(void)
+
+ return 0;
}

+static int sunxi_de_bind(struct udevice *dev)
+{
+ struct video_uc_plat *plat = dev_get_uclass_plat(dev);
+
+ plat->size = LCD_MAX_WIDTH * LCD_MAX_HEIGHT *
+ (1 << LCD_MAX_LOG2_BPP) / 8;
+
+ return 0;
+}
+
+static const struct video_ops sunxi_de_ops = {
+};
+
+U_BOOT_DRIVER(sunxi_de) = {
+ .name = "sunxi_de",
+ .id = UCLASS_VIDEO,
+ .ops = &sunxi_de_ops,
+ .bind = sunxi_de_bind,
+ .probe = sunxi_de_probe,
+ .priv_auto = sizeof(struct sunxi_display),
+ .flags = DM_FLAG_PRE_RELOC,
+};
+
+U_BOOT_DRVINFO(sunxi_de) = {
+ .name = "sunxi_de"
+};
+
/*
* Simplefb support.
*/
#if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_VIDEO_DT_SIMPLEFB)
int sunxi_simplefb_setup(void *blob)
{
- static GraphicDevice *graphic_device = &sunxi_display.graphic_device;
+ struct sunxi_display *sunxi_display;
+ struct video_priv *uc_priv;
+ struct udevice *de;
int offset, ret;
u64 start, size;
const char *pipeline = NULL;
@@ -1242,7 +1271,19 @@ int sunxi_simplefb_setup(void *blob)
#define PIPELINE_PREFIX
#endif

- switch (sunxi_display.monitor) {
+ ret = uclass_find_device_by_name(UCLASS_VIDEO, "sunxi_de", &de);
+ if (ret) {
+ printf("DE not present\n");
+ return 0;
+ } else if (!device_active(de)) {
+ printf("DE is present but not probed\n");
+ return 0;
+ }
+
+ uc_priv = dev_get_uclass_priv(de);
+ sunxi_display = dev_get_priv(de);
+
+ switch (sunxi_display->monitor) {
case sunxi_monitor_none:
return 0;
case sunxi_monitor_dvi:
@@ -1280,16 +1321,17 @@ int sunxi_simplefb_setup(void *blob)
* linux/arch/arm/mm/ioremap.c around line 301.
*/
start = gd->bd->bi_dram[0].start;
- size = gd->bd->bi_dram[0].size - sunxi_display.fb_size;
+ size = sunxi_display->fb_addr - start;
ret = fdt_fixup_memory_banks(blob, &start, &size, 1);
if (ret) {
eprintf("Cannot setup simplefb: Error reserving memory\n");
return ret;
}

- ret = fdt_setup_simplefb_node(blob, offset, sunxi_display.fb_addr,
- graphic_device->winSizeX, graphic_device->winSizeY,
- graphic_device->plnSizeX, "x8r8g8b8");
+ ret = fdt_setup_simplefb_node(blob, offset, sunxi_display->fb_addr,
+ uc_priv->xsize, uc_priv->ysize,
+ VNBYTES(uc_priv->bpix) * uc_priv->xsize,
+ "x8r8g8b8");
if (ret)
eprintf("Cannot setup simplefb: Error setting properties\n");

diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
index 000f3864702..97661329ba4 100644
--- a/include/configs/sunxi-common.h
+++ b/include/configs/sunxi-common.h
@@ -256,23 +256,6 @@ extern int soft_i2c_gpio_scl;
#endif
#endif /* ifdef CONFIG_REQUIRE_SERIAL_CONSOLE */

-#ifdef CONFIG_VIDEO_SUNXI
-/*
- * The amount of RAM to keep free at the top of RAM when relocating u-boot,
- * to use as framebuffer. This must be a multiple of 4096.
- */
-#define CONFIG_SUNXI_MAX_FB_SIZE (16 << 20)
-
-#define CONFIG_VIDEO_LOGO
-#define CONFIG_VIDEO_STD_TIMINGS
-#define CONFIG_I2C_EDID
-#define VIDEO_LINE_LEN (pGD->plnSizeX)
-
-/* allow both serial and cfb console. */
-/* stop x86 thinking in cfbconsole from trying to init a pc keyboard */
-
-#endif /* CONFIG_VIDEO_SUNXI */
-
/* Ethernet support */

#ifdef CONFIG_USB_EHCI_HCD
diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt
index c6a83124956..ed469f74034 100644
--- a/scripts/config_whitelist.txt
+++ b/scripts/config_whitelist.txt
@@ -1661,7 +1661,6 @@ CONFIG_STV0991
CONFIG_STV0991_HZ
CONFIG_STV0991_HZ_CLOCK
CONFIG_ST_SMI
-CONFIG_SUNXI_MAX_FB_SIZE
CONFIG_SXNI855T
CONFIG_SYSFLAGS_ADDR
CONFIG_SYSFS
--
2.17.5

Maxime Ripard

unread,
Feb 5, 2021, 11:04:41 AM2/5/21
to Andre Przywara, Jagan Teki, Anatolij Gustschin, u-b...@lists.denx.de, Simon Glass, Tom Rini, Jernej Skrabec, Icenowy Zheng, Priit Laes, Chen-Yu Tsai, linux...@googlegroups.com
On Fri, Feb 05, 2021 at 01:07:48AM +0000, Andre Przywara wrote:
> From: Jagan Teki <ja...@amarulasolutions.com>
>
> DM_VIDEO migration deadline is already expired, but around
> 80 Allwinner boards are still using video in a legacy way.
>
> ===================== WARNING ======================
> This board does not use CONFIG_DM_VIDEO Please update
> the board to use CONFIG_DM_VIDEO before the v2019.07 release.
> Failure to update by the deadline may result in board removal.
> See doc/driver-model/migration.rst for more info.
> ====================================================
>
> Convert the legacy video driver over to the DM_VIDEO framework. This is
> a minimal conversion: it doesn't use the DT for finding its resources,
> nor does it use DM clocks or DM devices for the outputs (LCD, HDMI, CVBS).
>
> Tested in Bananapi M1+ Plus 1920x1200 HDMI out. (Jagan)
>
> Signed-off-by: Jagan Teki <ja...@amarulasolutions.com>
> [Andre: rebase and smaller fixes]
> Signed-off-by: Andre Przywara <andre.p...@arm.com>

Acked-by: Maxime Ripard <mri...@kernel.org>

Thanks!
Maxime

Jernej Å krabec

unread,
Feb 5, 2021, 11:27:30 AM2/5/21
to Jagan Teki, Anatolij Gustschin, Andre Przywara, u-b...@lists.denx.de, Maxime Ripard, Simon Glass, Tom Rini, Icenowy Zheng, Priit Laes, Chen-Yu Tsai, linux...@googlegroups.com
Dne petek, 05. februar 2021 ob 02:07:48 CET je Andre Przywara napisal(a):
<snip>
This file has another ifdef which can be removed (#ifdef CONFIG_VIDEO).

After that,
Reviewed-by: Jernej Skrabec <jernej....@siol.net>

Best regards,
Jernej

Andre Przywara

unread,
Feb 5, 2021, 2:32:29 PM2/5/21
to Jernej Å krabec, Jagan Teki, Anatolij Gustschin, u-b...@lists.denx.de, Maxime Ripard, Simon Glass, Tom Rini, Icenowy Zheng, Priit Laes, Chen-Yu Tsai, linux...@googlegroups.com
Ah, indeed, thanks for pointing this out.

I think they are even more cleanups lurking in the shadows ;-)

> After that,
> Reviewed-by: Jernej Skrabec <jernej....@siol.net>

Thanks!
Andre

Simon Glass

unread,
Feb 7, 2021, 9:37:49 AM2/7/21
to Andre Przywara, Jagan Teki, Anatolij Gustschin, U-Boot Mailing List, Maxime Ripard, Tom Rini, Jernej Skrabec, Icenowy Zheng, Priit Laes, Chen-Yu Tsai, linux-sunxi
Hi Andre,
Reviewed-by: Simon Glass <s...@chromium.org>

Some thoughts below

> diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
> index 0135575ca1e..a29d11505aa 100644
> --- a/arch/arm/mach-sunxi/Kconfig
> +++ b/arch/arm/mach-sunxi/Kconfig
> @@ -816,13 +816,14 @@ config VIDEO_SUNXI
> depends on !MACH_SUN9I
> depends on !MACH_SUN50I
> depends on !SUN50I_GEN_H6
> - select VIDEO
> + select DM_VIDEO

I wonder whether instead VIDEO_SUNXI should depend on DM_VIDEO ?
Do you need that? Internal things should be avoided if posssible.

> #include "../videomodes.h"
> #include "../anx9804.h"
> #include "../hitachi_tx18d42vm_lcd.h"
> @@ -45,6 +49,11 @@
>
> DECLARE_GLOBAL_DATA_PTR;
>
> +/* Maximum LCD size we support */
> +#define LCD_MAX_WIDTH 3840
> +#define LCD_MAX_HEIGHT 2160
> +#define LCD_MAX_LOG2_BPP VIDEO_BPP32
> +
> enum sunxi_monitor {
> sunxi_monitor_none,
> sunxi_monitor_dvi,
> @@ -59,12 +68,11 @@ enum sunxi_monitor {
> #define SUNXI_MONITOR_LAST sunxi_monitor_composite_pal_nc
>
> struct sunxi_display {
> - GraphicDevice graphic_device;
> enum sunxi_monitor monitor;
> unsigned int depth;
> unsigned int fb_addr;
> unsigned int fb_size;

These last three are repeated from the uclass info. But fb_addr seems
to sometimes be different from the ucass frame buffer, in which case I
wonder how output actually works.

If you do actually need these, can you please document them here?

> -} sunxi_display;
> +};
>
> const struct ctfb_res_modes composite_video_modes[2] = {
> /* x y hz pixclk ps/kHz le ri up lo hs vs s vmode */

[..]

> -static void sunxi_mode_set(const struct ctfb_res_modes *mode,
> +static void sunxi_mode_set(struct sunxi_display *sunxi_display,
> + const struct ctfb_res_modes *mode,
> unsigned int address)
> {
> + enum sunxi_monitor monitor = sunxi_display->monitor;
> int __maybe_unused clk_div, clk_double;
> struct sunxi_lcdc_reg * const lcdc =
> (struct sunxi_lcdc_reg *)SUNXI_LCD0_BASE;
> struct sunxi_tve_reg * __maybe_unused const tve =
> (struct sunxi_tve_reg *)SUNXI_TVE0_BASE;
>
> - switch (sunxi_display.monitor) {
> + switch (sunxi_display->monitor) {
> case sunxi_monitor_none:
> break;
> case sunxi_monitor_dvi:
> case sunxi_monitor_hdmi:
> #ifdef CONFIG_VIDEO_HDMI

I wonder if all of these can use IS_ENABLED()?

> - sunxi_composer_mode_set(mode, address);
> - sunxi_lcdc_tcon1_mode_set(mode, &clk_div, &clk_double, 0);
> - sunxi_hdmi_mode_set(mode, clk_div, clk_double);
> + sunxi_composer_mode_set(mode, address, monitor);
> + sunxi_lcdc_tcon1_mode_set(mode, &clk_div, &clk_double, 0, monitor);
> + sunxi_hdmi_mode_set(mode, clk_div, clk_double, monitor);
> sunxi_composer_enable();
> - lcdc_enable(lcdc, sunxi_display.depth);
> + lcdc_enable(lcdc, sunxi_display->depth);
> sunxi_hdmi_enable();
> #endif
> break;

[..]

> -void *video_hw_init(void)
> +static int sunxi_de_probe(struct udevice *dev)

This function is way too long and would benefit from splitting into
several parts IMO.
ALIGN(overscan_offset, 0x100) ?

> + memset((void *)sunxi_display->fb_addr, 0, sunxi_display->fb_size);
> + flush_cache(sunxi_display->fb_addr, sunxi_display->fb_size);

Driver model clears the frame buffer. Is this needed?

> }
> - sunxi_mode_set(mode, fb_dma_addr);
> + sunxi_mode_set(sunxi_display, mode, fb_dma_addr);
>
> /*
> * These are the only members of this structure that are used. All the
> * others are driver specific. The pitch is stored in plnSizeX.
> */
> - graphic_device->frameAdrs = sunxi_display.fb_addr;
> - graphic_device->gdfIndex = GDF_32BIT_X888RGB;
> - graphic_device->gdfBytesPP = 4;
> - graphic_device->winSizeX = mode->xres - 2 * overscan_x;
> - graphic_device->winSizeY = mode->yres - 2 * overscan_y;
> - graphic_device->plnSizeX = mode->xres * graphic_device->gdfBytesPP;
> -
> - return graphic_device;
> + uc_priv->bpix = VIDEO_BPP32;
> + uc_priv->xsize = mode->xres;
> + uc_priv->ysize = mode->yres;
> +
> + video_set_flush_dcache(dev, 1);

true

> +
> + return 0;
> }
>
> +static int sunxi_de_bind(struct udevice *dev)
> +{
> + struct video_uc_plat *plat = dev_get_uclass_plat(dev);
> +
> + plat->size = LCD_MAX_WIDTH * LCD_MAX_HEIGHT *
> + (1 << LCD_MAX_LOG2_BPP) / 8;

Should use enum video_log2_bpp here. Also see VNBYTES().


> +
> + return 0;
> +}
> +
> +static const struct video_ops sunxi_de_ops = {
> +};
> +
> +U_BOOT_DRIVER(sunxi_de) = {
> + .name = "sunxi_de",
> + .id = UCLASS_VIDEO,
> + .ops = &sunxi_de_ops,
> + .bind = sunxi_de_bind,
> + .probe = sunxi_de_probe,
> + .priv_auto = sizeof(struct sunxi_display),

Should ideally have an _priv suffix

> + .flags = DM_FLAG_PRE_RELOC,
> +};
> +
> +U_BOOT_DRVINFO(sunxi_de) = {
> + .name = "sunxi_de"
> +};
> +

[..]

Regards,
Simon

Andre Przywara

unread,
Feb 7, 2021, 8:37:22 PM2/7/21
to Simon Glass, Jagan Teki, Anatolij Gustschin, U-Boot Mailing List, Maxime Ripard, Tom Rini, Jernej Skrabec, Icenowy Zheng, Priit Laes, Chen-Yu Tsai, linux-sunxi
On Sun, 7 Feb 2021 07:37:34 -0700
Simon Glass <s...@chromium.org> wrote:

Hi Simon,
Many thanks for having a thorough look, much appreciated.

I will have a closer look at your comments which I didn't reply to
below.

For the other points:
To be honest, I haven't checked every line in this patch, my goal was
merely to get it merged (this time), to prevent feature removal and
drop the nasty buildman warnings.
I see quite some cleanup potential here (some I already mentioned in
the commit message above), but wanted to get the main DM_VIDEO
conversion done first (as I think last time some discussion already
prevented a merge).
So my plan was to queue this for next ASAP, then send more cleanup patches
on top, before the next merge window. I understand that it's typically
done the other way around, but given this is dragging on for a while,
is long overdue and works for me (TM) as it is, I would prefer a
functional patch first, with cleanups on top.

>
> > diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
> > index 0135575ca1e..a29d11505aa 100644
> > --- a/arch/arm/mach-sunxi/Kconfig
> > +++ b/arch/arm/mach-sunxi/Kconfig
> > @@ -816,13 +816,14 @@ config VIDEO_SUNXI
> > depends on !MACH_SUN9I
> > depends on !MACH_SUN50I
> > depends on !SUN50I_GEN_H6
> > - select VIDEO
> > + select DM_VIDEO
>
> I wonder whether instead VIDEO_SUNXI should depend on DM_VIDEO ?

So I was always wondering about the logic behind that.
My understanding would be: This driver is (now) implementing the
DM_VIDEO interface. Any user (at board or SoC level) would just be
selecting this driver, without caring about which driver interface it
uses.
So as this driver is (now) DM_VIDEO only, it would signal this via this
select line.

If that is not how it's meant to be, can you explain the the idea behind
this, please?

Also: with CONFIG_VIDEO now dying, CONFIG_DM_VIDEO somewhat loses its
purpose, doesn't it?
Yes, in fact I have patches to replace all #ifdefs with IS_ENABLED(),
except the sun6i reset gate ones (which would break compilation on
non-sun6i). And those should be tackled by proper UCLASS_CLK usage.
But I wanted to get this basic conversion out first, see above.

The rest of your comments make sense on the first glance, I will try to
fix the easy things for a v4.

Cheers,
Andre

Simon Glass

unread,
Feb 7, 2021, 11:21:22 PM2/7/21
to Andre Przywara, Jagan Teki, Anatolij Gustschin, U-Boot Mailing List, Maxime Ripard, Tom Rini, Jernej Skrabec, Icenowy Zheng, Priit Laes, Chen-Yu Tsai, linux-sunxi
Hi Andre,
That's fine...you have my review tag. My comments are just suggestions
for improvement and much of it relates to the existing code.

>
> >
> > > diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
> > > index 0135575ca1e..a29d11505aa 100644
> > > --- a/arch/arm/mach-sunxi/Kconfig
> > > +++ b/arch/arm/mach-sunxi/Kconfig
> > > @@ -816,13 +816,14 @@ config VIDEO_SUNXI
> > > depends on !MACH_SUN9I
> > > depends on !MACH_SUN50I
> > > depends on !SUN50I_GEN_H6
> > > - select VIDEO
> > > + select DM_VIDEO
> >
> > I wonder whether instead VIDEO_SUNXI should depend on DM_VIDEO ?
>
> So I was always wondering about the logic behind that.
> My understanding would be: This driver is (now) implementing the
> DM_VIDEO interface. Any user (at board or SoC level) would just be
> selecting this driver, without caring about which driver interface it
> uses.
> So as this driver is (now) DM_VIDEO only, it would signal this via this
> select line.
>
> If that is not how it's meant to be, can you explain the the idea behind
> this, please?

That sounds fine to me, but what happens when someone selects a DM and
non-DM driver? That has always been the intent - to ensure that people
are selecting DM for a subsystem on purpose.

Of course these days most stuff is DM, so perhaps that approach is
obsolete and we should do what you say. I'm OK with that.

>
> Also: with CONFIG_VIDEO now dying, CONFIG_DM_VIDEO somewhat loses its
> purpose, doesn't it?

All of the CONFIG_DM... things should be removed at some point, yet.
Just waiting for the mythical deadlines...

[...]

Regards,
Simon

Andre Przywara

unread,
Feb 20, 2021, 7:08:52 PM2/20/21
to Simon Glass, Jagan Teki, Anatolij Gustschin, U-Boot Mailing List, Maxime Ripard, Tom Rini, Jernej Skrabec, Icenowy Zheng, Priit Laes, Chen-Yu Tsai, linux-sunxi
On Sun, 7 Feb 2021 07:37:34 -0700
Simon Glass <s...@chromium.org> wrote:

Hi Simon,

coming back to this patch, answering to the other comments I skipped
over the last time.

In general this patch is the shortest way to get to some kind of DM
driver, in many ways it still looks like a non-DM driver on the inside,
which shows.
That's a good point. This is needed for uclass_find_device_by_name()
down in the simplefb setup function at the very end. This function will
be called from a different context (from ft_board_setup() in board.c),
and tries to find the (only) instance of this very driver to populate
the simplefb DT node accordingly. This is the approach the sunxi_de2.c
uses, and back at the time this was seemingly the best way to achieve
this. Alternatives I see:
1) Keep a global static variable, pointing to the struct udevice, set in
probe().
2) Use uclass_get_device_by_name() instead, but prevent the double
probe by keeping an indication of the probe status.
3) Gather all data needed for the simplefb setup already in probe(),
and store them in global variables, to be picked up by
sunxi_simplefb_setup() later.
4) as 3), but store the extra data (just the pipeline name to find the
right DT node to enable?) in generic uclass storage. This has the
potential of making this function platform and board agnostic (so meson
could benefit as well?). We could then setup the simplefb in common
code.

Any ideas on this? Maybe something else entirely?

>
> > #include "../videomodes.h"
> > #include "../anx9804.h"
> > #include "../hitachi_tx18d42vm_lcd.h"
> > @@ -45,6 +49,11 @@
> >
> > DECLARE_GLOBAL_DATA_PTR;
> >
> > +/* Maximum LCD size we support */
> > +#define LCD_MAX_WIDTH 3840
> > +#define LCD_MAX_HEIGHT 2160
> > +#define LCD_MAX_LOG2_BPP VIDEO_BPP32

So this resolution is not achievable with a maximum pixel clock
of 165 MHz (not even at 24 Hz). Given that the framebuffer reservation
is fixed, this wastes quite some memory. Realistically 165 MHz means
1920x1200 (at 60Hz), shall we use that one instead?

> > +
> > enum sunxi_monitor {
> > sunxi_monitor_none,
> > sunxi_monitor_dvi,
> > @@ -59,12 +68,11 @@ enum sunxi_monitor {
> > #define SUNXI_MONITOR_LAST sunxi_monitor_composite_pal_nc
> >
> > struct sunxi_display {
> > - GraphicDevice graphic_device;
> > enum sunxi_monitor monitor;
> > unsigned int depth;
> > unsigned int fb_addr;
> > unsigned int fb_size;
>
> These last three are repeated from the uclass info. But fb_addr seems
> to sometimes be different from the ucass frame buffer, in which case I
> wonder how output actually works.
>
> If you do actually need these, can you please document them here?

I think this might be mostly non-DM legacy, but for the composite
overscan we tweak the framebuffer address. I haven't fully wrapped
my mind around this, though, and ideally we can indeed lose those
extra members.
I will try to find some device with composite input to test it.
Yeah, indeed. I started working on this, but it probably won't be part
of the next version already.
This is just when overscan is enabled (for composite video). I *think*
it aims to clear the unused overscan area?
LCD_MAX_LOG2_BPP is defined as VIDEO_BPP32 at the very top. Sure will
use VNBYTES.

On a related topic: IIUC this is called several times, for a start once
before relocation, where it's supposed to give an upper bound?
Are subsequent calls then expected to be more precise? Our 32MB frame
buffer is *very* generous, for the usual FullHD display we just need
8MB. But we would only know this in probe(), when we have learned the
output device and the video modes it supports.
So is there a way to restrict (and possibly also move) the framebuffer
in probe()?

Cheers,
Andre

Tom Rini

unread,
Feb 20, 2021, 7:45:22 PM2/20/21
to Andre Przywara, Simon Glass, Jagan Teki, Anatolij Gustschin, U-Boot Mailing List, Maxime Ripard, Jernej Skrabec, Icenowy Zheng, Priit Laes, Chen-Yu Tsai, linux-sunxi
On Sun, Feb 21, 2021 at 12:07:35AM +0000, Andre Przywara wrote:

> On Sun, 7 Feb 2021 07:37:34 -0700
> Simon Glass <s...@chromium.org> wrote:
>
> Hi Simon,
>
> coming back to this patch, answering to the other comments I skipped
> over the last time.
>
> In general this patch is the shortest way to get to some kind of DM
> driver, in many ways it still looks like a non-DM driver on the inside,
> which shows.

For the record, I'm OK with pulling this patch in as-is and improving
the situation rather than requiring further changes right now.

--
Tom
signature.asc

Simon Glass

unread,
Feb 21, 2021, 11:24:34 AM2/21/21
to Andre Przywara, Jagan Teki, Anatolij Gustschin, U-Boot Mailing List, Maxime Ripard, Tom Rini, Jernej Skrabec, Icenowy Zheng, Priit Laes, Chen-Yu Tsai, linux-sunxi
Hi Andre,
Best avoided.

> 2) Use uclass_get_device_by_name() instead, but prevent the double
> probe by keeping an indication of the probe status.

Probing a probed device is a nop, so don't worry about that. We do it
all the time.

> 3) Gather all data needed for the simplefb setup already in probe(),
> and store them in global variables, to be picked up by
> sunxi_simplefb_setup() later.

Again, best to avoid a global.

> 4) as 3), but store the extra data (just the pipeline name to find the
> right DT node to enable?) in generic uclass storage. This has the
> potential of making this function platform and board agnostic (so meson
> could benefit as well?). We could then setup the simplefb in common
> code.
>
> Any ideas on this? Maybe something else entirely?

I think what you have is OK...at present those functions are not
called in device context. I don't really have a good solution. You
want to avoid probing it just to fill in the data.

BTW it is a bit faster to call
device_get_by_driver_info(DM_DRIVER_GET(sunxi_de), &dev)

>
> >
> > > #include "../videomodes.h"
> > > #include "../anx9804.h"
> > > #include "../hitachi_tx18d42vm_lcd.h"
> > > @@ -45,6 +49,11 @@
> > >
> > > DECLARE_GLOBAL_DATA_PTR;
> > >
> > > +/* Maximum LCD size we support */
> > > +#define LCD_MAX_WIDTH 3840
> > > +#define LCD_MAX_HEIGHT 2160
> > > +#define LCD_MAX_LOG2_BPP VIDEO_BPP32
>
> So this resolution is not achievable with a maximum pixel clock
> of 165 MHz (not even at 24 Hz). Given that the framebuffer reservation
> is fixed, this wastes quite some memory. Realistically 165 MHz means
> 1920x1200 (at 60Hz), shall we use that one instead?

I'm not sure about that, but I suppose if the maximum is too high you
can change it.

>
> > > +
> > > enum sunxi_monitor {
> > > sunxi_monitor_none,
> > > sunxi_monitor_dvi,
> > > @@ -59,12 +68,11 @@ enum sunxi_monitor {
> > > #define SUNXI_MONITOR_LAST sunxi_monitor_composite_pal_nc
> > >
> > > struct sunxi_display {
> > > - GraphicDevice graphic_device;
> > > enum sunxi_monitor monitor;
> > > unsigned int depth;
> > > unsigned int fb_addr;
> > > unsigned int fb_size;
> >
> > These last three are repeated from the uclass info. But fb_addr seems
> > to sometimes be different from the ucass frame buffer, in which case I
> > wonder how output actually works.
> >
> > If you do actually need these, can you please document them here?
>
> I think this might be mostly non-DM legacy, but for the composite
> overscan we tweak the framebuffer address. I haven't fully wrapped
> my mind around this, though, and ideally we can indeed lose those
> extra members.
> I will try to find some device with composite input to test it.

Ah OK. Well yes it needs some docs for the next person :-)


[..]
In that case I feel that the fb should be allocated large enough for
the overscan area (how else could it be). But I'm not sure what is
happening here, so perhaps this is needed.
I suppose you can, but that is not what is expected. You don't save
memory for U-Boot (and it doesn't matter), but making it smaller so
that linux uses less would be worthwhile. We just need to make sure
this is documented in video.h and tested.

To be clear, you have my review thg, so these are things that can be done later.

Regards,
Simon

Andre Przywara

unread,
Feb 21, 2021, 7:13:46 PM2/21/21
to Jagan Teki, Anatolij Gustschin, u-b...@lists.denx.de, Maxime Ripard, Simon Glass, Tom Rini, Jernej Skrabec, Icenowy Zheng, Priit Laes, Chen-Yu Tsai, linux...@googlegroups.com
From: Jagan Teki <ja...@amarulasolutions.com>

DM_VIDEO migration deadline is already expired, but around
80 Allwinner boards are still using video in a legacy way:

===================== WARNING ======================
This board does not use CONFIG_DM_VIDEO Please update
the board to use CONFIG_DM_VIDEO before the v2019.07 release.
Failure to update by the deadline may result in board removal.
See doc/driver-model/migration.rst for more info.
====================================================

Convert the legacy video driver over to the DM_VIDEO framework. This is
a minimal conversion: it doesn't use the DT for finding its resources,
nor does it use DM clocks or DM devices for the outputs (LCD, HDMI, CVBS).

Tested in Bananapi M1+ Plus 1920x1200 HDMI out. (Jagan)

Signed-off-by: Jagan Teki <ja...@amarulasolutions.com>
[Andre: rebase and smaller fixes]
Signed-off-by: Andre Przywara <andre.p...@arm.com>
Acked-by: Maxime Ripard <mri...@kernel.org>
Reviewed-by: Jernej Skrabec <jernej....@siol.net>
Reviewed-by: Simon Glass <s...@chromium.org>
---
Hi,

some very small fixes, to address Jernej's and Simon's comments.
As we figured, there is more improvement potential, but this should
be a good first step.

Cheers,
Andre

Changelog v3 .. v4:
- remove no longer needed definitions in sunxi-common.h
- rename struct sunxi_display to struct sunxi_display_priv
- use VNBYTES to calculate bit depth
- use ALIGN instead of open coding it

Changelog v2 .. v3:
- rebase against master, fixing up renamed variables and structs
- replace enum with #define
- remove BMP from Kconfig
- fix memory node size calculation in simplefb setup

arch/arm/mach-sunxi/Kconfig | 9 +-
drivers/video/sunxi/sunxi_display.c | 268 ++++++++++++++++------------
include/configs/sunxi-common.h | 23 +--
scripts/config_whitelist.txt | 1 -
4 files changed, 159 insertions(+), 142 deletions(-)

diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
index 0135575ca1e..a29d11505aa 100644
--- a/arch/arm/mach-sunxi/Kconfig
+++ b/arch/arm/mach-sunxi/Kconfig
@@ -816,13 +816,14 @@ config VIDEO_SUNXI
depends on !MACH_SUN9I
depends on !MACH_SUN50I
depends on !SUN50I_GEN_H6
- select VIDEO
+ select DM_VIDEO
+ select DISPLAY
imply VIDEO_DT_SIMPLEFB
default y
---help---
- Say Y here to add support for using a cfb console on the HDMI, LCD
- or VGA output found on most sunxi devices. See doc/README.video for
- info on how to select the video output and mode.
+ Say Y here to add support for using a graphical console on the HDMI,
+ LCD or VGA output found on older sunxi devices. This will also provide
+ a simple_framebuffer device for Linux.

config VIDEO_HDMI
bool "HDMI output support"
diff --git a/drivers/video/sunxi/sunxi_display.c b/drivers/video/sunxi/sunxi_display.c
index f52aba4d21c..4361a58cd7e 100644
--- a/drivers/video/sunxi/sunxi_display.c
+++ b/drivers/video/sunxi/sunxi_display.c
@@ -7,6 +7,8 @@
*/

#include <common.h>
+#include <display.h>
+#include <dm.h>
#include <cpu_func.h>
#include <efi_loader.h>
#include <init.h>
@@ -28,7 +30,9 @@
#include <fdt_support.h>
#include <i2c.h>
#include <malloc.h>
+#include <video.h>
#include <video_fb.h>
+#include <dm/uclass-internal.h>
#include "../videomodes.h"
#include "../anx9804.h"
#include "../hitachi_tx18d42vm_lcd.h"
@@ -45,6 +49,11 @@

DECLARE_GLOBAL_DATA_PTR;

+/* Maximum LCD size we support */
+#define LCD_MAX_WIDTH 3840
+#define LCD_MAX_HEIGHT 2160
+#define LCD_MAX_LOG2_BPP VIDEO_BPP32
+
enum sunxi_monitor {
sunxi_monitor_none,
sunxi_monitor_dvi,
@@ -58,13 +67,12 @@ enum sunxi_monitor {
};
#define SUNXI_MONITOR_LAST sunxi_monitor_composite_pal_nc

-struct sunxi_display {
- GraphicDevice graphic_device;
+struct sunxi_display_priv {
enum sunxi_monitor monitor;
unsigned int depth;
unsigned int fb_addr;
unsigned int fb_size;
-} sunxi_display;
+};

const struct ctfb_res_modes composite_video_modes[2] = {
/* x y hz pixclk ps/kHz le ri up lo hs vs s vmode */
@@ -214,7 +222,8 @@ static int sunxi_hdmi_edid_get_block(int block, u8 *buf)
return r;
}

-static int sunxi_hdmi_edid_get_mode(struct ctfb_res_modes *mode,
+static int sunxi_hdmi_edid_get_mode(struct sunxi_display_priv *sunxi_display,
+ struct ctfb_res_modes *mode,
bool verbose_mode)
{
struct edid1_info edid1;
@@ -291,14 +300,14 @@ static int sunxi_hdmi_edid_get_mode(struct ctfb_res_modes *mode,
}

/* Check for basic audio support, if found enable hdmi output */
- sunxi_display.monitor = sunxi_monitor_dvi;
+ sunxi_display->monitor = sunxi_monitor_dvi;
for (i = 0; i < ext_blocks; i++) {
if (cea681[i].extension_tag != EDID_CEA861_EXTENSION_TAG ||
cea681[i].revision < 2)
continue;

if (EDID_CEA861_SUPPORTS_BASIC_AUDIO(cea681[i]))
- sunxi_display.monitor = sunxi_monitor_hdmi;
+ sunxi_display->monitor = sunxi_monitor_hdmi;
}

return 0;
@@ -414,9 +423,9 @@ static void sunxi_frontend_mode_set(const struct ctfb_res_modes *mode,
static void sunxi_frontend_enable(void) {}
#endif

-static bool sunxi_is_composite(void)
+static bool sunxi_is_composite(enum sunxi_monitor monitor)
{
- switch (sunxi_display.monitor) {
+ switch (monitor) {
case sunxi_monitor_none:
case sunxi_monitor_dvi:
case sunxi_monitor_hdmi:
@@ -473,7 +482,8 @@ static const u32 sunxi_rgb2yuv_coef[12] = {
};

static void sunxi_composer_mode_set(const struct ctfb_res_modes *mode,
- unsigned int address)
+ unsigned int address,
+ enum sunxi_monitor monitor)
{
struct sunxi_de_be_reg * const de_be =
(struct sunxi_de_be_reg *)SUNXI_DE_BE0_BASE;
@@ -502,7 +512,7 @@ static void sunxi_composer_mode_set(const struct ctfb_res_modes *mode,
#endif
SUNXI_DE_BE_MODE_INTERLACE_ENABLE);

- if (sunxi_is_composite()) {
+ if (sunxi_is_composite(monitor)) {
writel(SUNXI_DE_BE_OUTPUT_COLOR_CTRL_ENABLE,
&de_be->output_color_ctrl);
for (i = 0; i < 12; i++)
@@ -616,7 +626,8 @@ static void sunxi_lcdc_backlight_enable(void)
gpio_direction_output(pin, PWM_ON);
}

-static void sunxi_lcdc_tcon0_mode_set(const struct ctfb_res_modes *mode,
+static void sunxi_lcdc_tcon0_mode_set(struct sunxi_display_priv *sunxi_display,
+ const struct ctfb_res_modes *mode,
bool for_ext_vga_dac)
{
struct sunxi_lcdc_reg * const lcdc =
@@ -643,17 +654,18 @@ static void sunxi_lcdc_tcon0_mode_set(const struct ctfb_res_modes *mode,
}

lcdc_pll_set(ccm, 0, mode->pixclock_khz, &clk_div, &clk_double,
- sunxi_is_composite());
+ sunxi_is_composite(sunxi_display->monitor));

video_ctfb_mode_to_display_timing(mode, &timing);
lcdc_tcon0_mode_set(lcdc, &timing, clk_div, for_ext_vga_dac,
- sunxi_display.depth, CONFIG_VIDEO_LCD_DCLK_PHASE);
+ sunxi_display->depth, CONFIG_VIDEO_LCD_DCLK_PHASE);
}

#if defined CONFIG_VIDEO_HDMI || defined CONFIG_VIDEO_VGA || defined CONFIG_VIDEO_COMPOSITE
static void sunxi_lcdc_tcon1_mode_set(const struct ctfb_res_modes *mode,
int *clk_div, int *clk_double,
- bool use_portd_hvsync)
+ bool use_portd_hvsync,
+ enum sunxi_monitor monitor)
{
struct sunxi_lcdc_reg * const lcdc =
(struct sunxi_lcdc_reg *)SUNXI_LCD0_BASE;
- switch (sunxi_display.monitor) {
+ switch (monitor) {
case sunxi_monitor_vga:
tvencoder_mode_set(tve, tve_mode_vga);
break;
@@ -896,26 +909,28 @@ static void sunxi_engines_init(void)
sunxi_drc_init();
}

-static void sunxi_mode_set(const struct ctfb_res_modes *mode,
+static void sunxi_mode_set(struct sunxi_display_priv *sunxi_display,
+ const struct ctfb_res_modes *mode,
unsigned int address)
{
+ enum sunxi_monitor monitor = sunxi_display->monitor;
int __maybe_unused clk_div, clk_double;
struct sunxi_lcdc_reg * const lcdc =
(struct sunxi_lcdc_reg *)SUNXI_LCD0_BASE;
struct sunxi_tve_reg * __maybe_unused const tve =
(struct sunxi_tve_reg *)SUNXI_TVE0_BASE;

- switch (sunxi_display.monitor) {
+ switch (sunxi_display->monitor) {
case sunxi_monitor_none:
break;
case sunxi_monitor_dvi:
case sunxi_monitor_hdmi:
#ifdef CONFIG_VIDEO_HDMI
- sunxi_composer_mode_set(mode, address);
- sunxi_lcdc_tcon1_mode_set(mode, &clk_div, &clk_double, 0);
- sunxi_hdmi_mode_set(mode, clk_div, clk_double);
+ sunxi_composer_mode_set(mode, address, monitor);
+ sunxi_lcdc_tcon1_mode_set(mode, &clk_div, &clk_double, 0, monitor);
+ sunxi_hdmi_mode_set(mode, clk_div, clk_double, monitor);
sunxi_composer_enable();
- lcdc_enable(lcdc, sunxi_display.depth);
+ lcdc_enable(lcdc, sunxi_display->depth);
sunxi_hdmi_enable();
#endif
break;
@@ -930,7 +945,7 @@ static void sunxi_mode_set(const struct ctfb_res_modes *mode,
axp_set_eldo(3, 1800);
anx9804_init(CONFIG_VIDEO_LCD_I2C_BUS, 4,
ANX9804_DATA_RATE_1620M,
- sunxi_display.depth);
+ sunxi_display->depth);
}
if (IS_ENABLED(CONFIG_VIDEO_LCD_HITACHI_TX18D42VM)) {
mdelay(50); /* Wait for lcd controller power on */
@@ -942,10 +957,10 @@ static void sunxi_mode_set(const struct ctfb_res_modes *mode,
i2c_reg_write(0x5c, 0x04, 0x42); /* Turn on the LCD */
i2c_set_bus_num(orig_i2c_bus);
}
- sunxi_composer_mode_set(mode, address);
- sunxi_lcdc_tcon0_mode_set(mode, false);
+ sunxi_composer_mode_set(mode, address, monitor);
+ sunxi_lcdc_tcon0_mode_set(sunxi_display, mode, false);
sunxi_composer_enable();
- lcdc_enable(lcdc, sunxi_display.depth);
+ lcdc_enable(lcdc, sunxi_display->depth);
#ifdef CONFIG_VIDEO_LCD_SSD2828
sunxi_ssd2828_init(mode);
#endif
@@ -953,17 +968,17 @@ static void sunxi_mode_set(const struct ctfb_res_modes *mode,
break;
case sunxi_monitor_vga:
#ifdef CONFIG_VIDEO_VGA
- sunxi_composer_mode_set(mode, address);
- sunxi_lcdc_tcon1_mode_set(mode, &clk_div, &clk_double, 1);
- sunxi_tvencoder_mode_set();
+ sunxi_composer_mode_set(mode, address, monitor);
+ sunxi_lcdc_tcon1_mode_set(mode, &clk_div, &clk_double, 1, monitor);
+ sunxi_tvencoder_mode_set(monitor);
sunxi_composer_enable();
- lcdc_enable(lcdc, sunxi_display.depth);
+ lcdc_enable(lcdc, sunxi_display->depth);
tvencoder_enable(tve);
#elif defined CONFIG_VIDEO_VGA_VIA_LCD
- sunxi_composer_mode_set(mode, address);
- sunxi_lcdc_tcon0_mode_set(mode, true);
+ sunxi_composer_mode_set(mode, address, monitor);
+ sunxi_lcdc_tcon0_mode_set(sunxi_display, mode, true);
sunxi_composer_enable();
- lcdc_enable(lcdc, sunxi_display.depth);
+ lcdc_enable(lcdc, sunxi_display->depth);
sunxi_vga_external_dac_enable();
#endif
break;
@@ -972,11 +987,11 @@ static void sunxi_mode_set(const struct ctfb_res_modes *mode,
case sunxi_monitor_composite_pal_m:
case sunxi_monitor_composite_pal_nc:
#ifdef CONFIG_VIDEO_COMPOSITE
- sunxi_composer_mode_set(mode, address);
- sunxi_lcdc_tcon1_mode_set(mode, &clk_div, &clk_double, 0);
- sunxi_tvencoder_mode_set();
+ sunxi_composer_mode_set(mode, address, monitor);
+ sunxi_lcdc_tcon1_mode_set(mode, &clk_div, &clk_double, 0, monitor);
+ sunxi_tvencoder_mode_set(monitor);
sunxi_composer_enable();
- lcdc_enable(lcdc, sunxi_display.depth);
+ lcdc_enable(lcdc, sunxi_display->depth);
tvencoder_enable(tve);
#endif
break;
@@ -999,11 +1014,6 @@ static const char *sunxi_get_mon_desc(enum sunxi_monitor monitor)
}
}

-ulong board_get_usable_ram_top(ulong total_size)
-{
- return gd->ram_top - CONFIG_SUNXI_MAX_FB_SIZE;
-}
-
static bool sunxi_has_hdmi(void)
{
#ifdef CONFIG_VIDEO_HDMI
@@ -1052,9 +1062,11 @@ static enum sunxi_monitor sunxi_get_default_mon(bool allow_hdmi)
return sunxi_monitor_none;
}

-void *video_hw_init(void)
+static int sunxi_de_probe(struct udevice *dev)
{
- static GraphicDevice *graphic_device = &sunxi_display.graphic_device;
+ struct video_priv *uc_priv = dev_get_uclass_priv(dev);
+ struct video_uc_plat *plat = dev_get_uclass_plat(dev);
+ struct sunxi_display_priv *sunxi_display = dev_get_priv(dev);
@@ -1153,85 +1164,99 @@ void *video_hw_init(void)
printf("Setting up a %dx%d%s %s console (overscan %dx%d)\n",
mode->xres, mode->yres,
(mode->vmode == FB_VMODE_INTERLACED) ? "i" : "",
- sunxi_get_mon_desc(sunxi_display.monitor),
+ sunxi_get_mon_desc(sunxi_display->monitor),
overscan_x, overscan_y);

- gd->fb_base = gd->bd->bi_dram[0].start +
- gd->bd->bi_dram[0].size - sunxi_display.fb_size;
+ sunxi_display->fb_addr = plat->base;
sunxi_engines_init();

#ifdef CONFIG_EFI_LOADER
- efi_add_memory_map(gd->fb_base, sunxi_display.fb_size,
+ efi_add_memory_map(sunxi_display->fb_addr, sunxi_display->fb_size,
EFI_RESERVED_MEMORY_TYPE);
#endif

- fb_dma_addr = gd->fb_base - CONFIG_SYS_SDRAM_BASE;
- sunxi_display.fb_addr = gd->fb_base;
+ fb_dma_addr = sunxi_display->fb_addr - CONFIG_SYS_SDRAM_BASE;
if (overscan_offset) {
fb_dma_addr += 0x1000 - (overscan_offset & 0xfff);
- sunxi_display.fb_addr += (overscan_offset + 0xfff) & ~0xfff;
- memset((void *)gd->fb_base, 0, sunxi_display.fb_size);
- flush_cache(gd->fb_base, sunxi_display.fb_size);
+ sunxi_display->fb_addr += ALIGN(overscan_offset, 0x1000);
+ memset((void *)sunxi_display->fb_addr, 0, sunxi_display->fb_size);
+ flush_cache(sunxi_display->fb_addr, sunxi_display->fb_size);
}
- sunxi_mode_set(mode, fb_dma_addr);
+ sunxi_mode_set(sunxi_display, mode, fb_dma_addr);

- /*
- * These are the only members of this structure that are used. All the
- * others are driver specific. The pitch is stored in plnSizeX.
- */
- graphic_device->frameAdrs = sunxi_display.fb_addr;
- graphic_device->gdfIndex = GDF_32BIT_X888RGB;
- graphic_device->gdfBytesPP = 4;
- graphic_device->winSizeX = mode->xres - 2 * overscan_x;
- graphic_device->winSizeY = mode->yres - 2 * overscan_y;
- graphic_device->plnSizeX = mode->xres * graphic_device->gdfBytesPP;
-
- return graphic_device;
+ /* The members of struct video_priv to be set by the driver. */
+ uc_priv->bpix = VIDEO_BPP32;
+ uc_priv->xsize = mode->xres;
+ uc_priv->ysize = mode->yres;
+
+ video_set_flush_dcache(dev, true);
+
+ return 0;
}

+static int sunxi_de_bind(struct udevice *dev)
+{
+ struct video_uc_plat *plat = dev_get_uclass_plat(dev);
+
+ plat->size = LCD_MAX_WIDTH * LCD_MAX_HEIGHT * VNBYTES(LCD_MAX_LOG2_BPP);
+
+ return 0;
+}
+
+static const struct video_ops sunxi_de_ops = {
+};
+
+U_BOOT_DRIVER(sunxi_de) = {
+ .name = "sunxi_de",
+ .id = UCLASS_VIDEO,
+ .ops = &sunxi_de_ops,
+ .bind = sunxi_de_bind,
+ .probe = sunxi_de_probe,
+ .priv_auto = sizeof(struct sunxi_display_priv),
+ .flags = DM_FLAG_PRE_RELOC,
+};
+
+U_BOOT_DRVINFO(sunxi_de) = {
+ .name = "sunxi_de"
+};
+
/*
* Simplefb support.
*/
#if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_VIDEO_DT_SIMPLEFB)
int sunxi_simplefb_setup(void *blob)
{
- static GraphicDevice *graphic_device = &sunxi_display.graphic_device;
+ struct sunxi_display_priv *sunxi_display;
+ struct video_priv *uc_priv;
+ struct udevice *de;
int offset, ret;
u64 start, size;
const char *pipeline = NULL;
@@ -1242,7 +1267,19 @@ int sunxi_simplefb_setup(void *blob)
#define PIPELINE_PREFIX
#endif

- switch (sunxi_display.monitor) {
+ ret = uclass_find_device_by_name(UCLASS_VIDEO, "sunxi_de", &de);
+ if (ret) {
+ printf("DE not present\n");
+ return 0;
+ } else if (!device_active(de)) {
+ printf("DE is present but not probed\n");
+ return 0;
+ }
+
+ uc_priv = dev_get_uclass_priv(de);
+ sunxi_display = dev_get_priv(de);
+
+ switch (sunxi_display->monitor) {
case sunxi_monitor_none:
return 0;
case sunxi_monitor_dvi:
@@ -1280,16 +1317,17 @@ int sunxi_simplefb_setup(void *blob)
* linux/arch/arm/mm/ioremap.c around line 301.
*/
start = gd->bd->bi_dram[0].start;
- size = gd->bd->bi_dram[0].size - sunxi_display.fb_size;
+ size = sunxi_display->fb_addr - start;
ret = fdt_fixup_memory_banks(blob, &start, &size, 1);
if (ret) {
eprintf("Cannot setup simplefb: Error reserving memory\n");
return ret;
}

- ret = fdt_setup_simplefb_node(blob, offset, sunxi_display.fb_addr,
- graphic_device->winSizeX, graphic_device->winSizeY,
- graphic_device->plnSizeX, "x8r8g8b8");
+ ret = fdt_setup_simplefb_node(blob, offset, sunxi_display->fb_addr,
+ uc_priv->xsize, uc_priv->ysize,
+ VNBYTES(uc_priv->bpix) * uc_priv->xsize,
+ "x8r8g8b8");
if (ret)
eprintf("Cannot setup simplefb: Error setting properties\n");

diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
index ded5aea551d..e08cc2080ba 100644
--- a/include/configs/sunxi-common.h
+++ b/include/configs/sunxi-common.h
@@ -223,23 +223,6 @@ extern int soft_i2c_gpio_scl;
#define CONFIG_VIDEO_LCD_I2C_BUS -1 /* NA, but necessary to compile */
#endif

-#ifdef CONFIG_VIDEO_SUNXI
-/*
- * The amount of RAM to keep free at the top of RAM when relocating u-boot,
- * to use as framebuffer. This must be a multiple of 4096.
- */
-#define CONFIG_SUNXI_MAX_FB_SIZE (16 << 20)
-
-#define CONFIG_VIDEO_LOGO
-#define CONFIG_VIDEO_STD_TIMINGS
-#define CONFIG_I2C_EDID
-#define VIDEO_LINE_LEN (pGD->plnSizeX)
-
-/* allow both serial and cfb console. */
-/* stop x86 thinking in cfbconsole from trying to init a pc keyboard */
-
-#endif /* CONFIG_VIDEO_SUNXI */
-
/* Ethernet support */

#ifdef CONFIG_USB_EHCI_HCD
@@ -401,11 +384,7 @@ extern int soft_i2c_gpio_scl;
"stdin=serial\0"
#endif

-#ifdef CONFIG_VIDEO
-#define CONSOLE_STDOUT_SETTINGS \
- "stdout=serial,vga\0" \
- "stderr=serial,vga\0"
-#elif CONFIG_DM_VIDEO
+#ifdef CONFIG_DM_VIDEO
#define CONSOLE_STDOUT_SETTINGS \
"stdout=serial,vidconsole\0" \
"stderr=serial,vidconsole\0"
diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt
index cd59acdab86..471fbb732a3 100644
--- a/scripts/config_whitelist.txt
+++ b/scripts/config_whitelist.txt
@@ -1636,7 +1636,6 @@ CONFIG_STV0991

Andre Przywara

unread,
Feb 21, 2021, 7:18:18 PM2/21/21
to Anatolij Gustschin, Tom Rini, Simon Glass, Jagan Teki, U-Boot Mailing List, Maxime Ripard, Jernej Skrabec, Icenowy Zheng, Priit Laes, Chen-Yu Tsai, linux-sunxi
On Sun, 21 Feb 2021 17:47:53 +0100
Anatolij Gustschin <ag...@denx.de> wrote:

Hi Anatolij,
> OK, thanks! I'll queue it and will submit a pull request soon.

Thanks for that. I just sent a v4 with some small fixes and all the
tags.

And just to be sure: with "queue it" you mean for -next, so the April
merge window? Because I would feel less comfortable with merging it now,
as this has not been widely tested yet (only on A10 and A20, but not on
all those other SoCs, especially in tablets with native LCDs).

Thanks!
Andre.

Maxime Ripard

unread,
Feb 22, 2021, 3:59:56 AM2/22/21
to Andre Przywara, Simon Glass, Jagan Teki, Anatolij Gustschin, U-Boot Mailing List, Tom Rini, Jernej Skrabec, Icenowy Zheng, Priit Laes, Chen-Yu Tsai, linux-sunxi
Hi Andre,

On Sun, Feb 21, 2021 at 12:07:35AM +0000, Andre Przywara wrote:
> > > enum sunxi_monitor {
> > > sunxi_monitor_none,
> > > sunxi_monitor_dvi,
> > > @@ -59,12 +68,11 @@ enum sunxi_monitor {
> > > #define SUNXI_MONITOR_LAST sunxi_monitor_composite_pal_nc
> > >
> > > struct sunxi_display {
> > > - GraphicDevice graphic_device;
> > > enum sunxi_monitor monitor;
> > > unsigned int depth;
> > > unsigned int fb_addr;
> > > unsigned int fb_size;
> >
> > These last three are repeated from the uclass info. But fb_addr seems
> > to sometimes be different from the ucass frame buffer, in which case I
> > wonder how output actually works.
> >
> > If you do actually need these, can you please document them here?
>
> I think this might be mostly non-DM legacy, but for the composite
> overscan we tweak the framebuffer address. I haven't fully wrapped
> my mind around this, though, and ideally we can indeed lose those
> extra members.
> I will try to find some device with composite input to test it.

So the overscan will put the edges of any displayed image out of the
visible area of the screen, right? The amount of content non-visible due
to this isn't really standard and any display will behave differently
there.

One way to deal with this is to rescale the composited image to a
slightly smaller and center it in the middle of the screen.

We don't have that option though, so the code will instead render in a
slightly smaller resolution, centered in the framebuffer.

Note that composite isn't the only output that you can test this on:
HDMI TVs will also use overscan.
signature.asc

Maxime Ripard

unread,
Feb 22, 2021, 4:02:30 AM2/22/21
to Simon Glass, Andre Przywara, Jagan Teki, Anatolij Gustschin, U-Boot Mailing List, Tom Rini, Jernej Skrabec, Icenowy Zheng, Priit Laes, Chen-Yu Tsai, linux-sunxi
On Sun, Feb 21, 2021 at 09:24:18AM -0700, Simon Glass wrote:
> > > > +static int sunxi_de_bind(struct udevice *dev)
> > > > +{
> > > > + struct video_uc_plat *plat = dev_get_uclass_plat(dev);
> > > > +
> > > > + plat->size = LCD_MAX_WIDTH * LCD_MAX_HEIGHT *
> > > > + (1 << LCD_MAX_LOG2_BPP) / 8;
> > >
> > > Should use enum video_log2_bpp here. Also see VNBYTES().
> >
> > LCD_MAX_LOG2_BPP is defined as VIDEO_BPP32 at the very top. Sure will
> > use VNBYTES.
> >
> > On a related topic: IIUC this is called several times, for a start once
> > before relocation, where it's supposed to give an upper bound?
> > Are subsequent calls then expected to be more precise? Our 32MB frame
> > buffer is *very* generous, for the usual FullHD display we just need
> > 8MB. But we would only know this in probe(), when we have learned the
> > output device and the video modes it supports.
> > So is there a way to restrict (and possibly also move) the framebuffer
> > in probe()?
>
> I suppose you can, but that is not what is expected. You don't save
> memory for U-Boot (and it doesn't matter), but making it smaller so
> that linux uses less would be worthwhile. We just need to make sure
> this is documented in video.h and tested.
>
> To be clear, you have my review thg, so these are things that can be done later.

Seems Andre seems to be motivated to rework that driver, I guess we
could also rework how this is done.

Ideally, we should be describing the reserved buffer through a
reserved-memory node in the DT instead of carving out some memory for
Linux. That way, if we don't have simplefb support, or it's replaced by
something else eventually, we have a chance a claiming that memory back
at some point, instead of just ignoring it.

Maxime
signature.asc
Reply all
Reply to author
Forward
0 new messages