video: sunxi: Convert DM_VIDEO
v2 cover video: sunxi: Convert DM_VIDEO
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
Signature · 1 line
2.25.1
PATCH v2 1/3 logos: Add sunxi logo
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
---
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
tools/logos/sunxi.bmp new file binary +0 -0
zkppr?5fnu94-rH}K at da~K}12sKg6pb3W|sbqWHk~>(1<+lP at Y?8^3b at xR9wiXLfdW z=Cx6vzwr=TU-i^{xuQ6j at -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$)c1e3GX0sU<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 at bKY7c=YHIJbwHbo;-O1 zPoF-8XV0F&^XJdu#fum4^5si-{rWY$di4t4ym<p}- at b)+ at 7}?O4<F$D}gqi<45 at P z=@WeZ{29J{2t_ReuZz}zQOnJ-{HrPA61D{XX_EDN1z^odIahbs7Ih4fqDe$5%|Xu z5ZFlm)QnWikY~-GH8jnC at 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 zF2tSV+dCx%@aoI;$3Xs0a~R}2$gJ6#8Qmt$#NeGaj|M841v_0=TAqOjub^Kpz;c z2#JZaW!L))I8z=M=O7On^JVHKrIbSi7M8Sw>GYti+*&IXoUCa8?N_K6vs0kK%AutD zLw!TkS?(f}dLP2h8kqH<I;M@aTueVM3FKdi^3ZkDD!N&JO%JFPp^<=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#xkldCH^^A7YQ(atRr_AX3!0 at ski2BQ*R zHh}glwtcl?0dqg9XT3BFByy_sBGV)z6W6Qa7HpKl)M&(c=UPM_pi&=2p~plcaanf z7U;8*1j$VS?c)5XPXQb<sz+3F;G#T@;xGqIdq9N(4w?IT9ndxw*(eik(5arqmn zG16{ED!JGKAwDNr3G(2MiUpvJB8#iSsg)L(u(0Aaz=Z<XNt5MvQs^v(-s%69Q#b z6we_J+R0X_oMPZe)I<joB~NYC5=qKgw(T&=QV7Q?5wap9qoyuE1I;f@$bP!{Gz at a z1vwAU2IiHA@JN1aDy29r5kuDy$95kJsiqIgeZwRJ}to>VL_(q*+{t?=S2+!YaCZ3 zLuEz83 at 8Le2PI|P2tgbm)4pS5WK+RitX-e1bO=PW?9tRleiIh6FUAWg6$h|WCL|;^ z_?9SQ8N#vxIvICQNY8S-8w&{5q>Mw=;@O7dhUf?)o2Cf123W<$*2qNqEGCk}KcMY zkRD|=vXV5ZmlsnXpnWrL00mUNlooVf3B&@jG<1W?1GD0rtqv$$w<GQ=x!<9ZL z1;G|zRSpND3pUhDR#JFXU}Wk>EW=b*M7$@Iq64&-1DMP0$P}~#r&&g6o~D%V<l{uj zCt1ZhA_g at kxFD1qoQg?)4KvXkQ;jMX1Fc2QiRmMT at 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)Va4 zAwVadmr?~uW>uq+Lh56QYNJ9|aN>Q75?vW&X-6|Es>w4t7~qF}zMFO|h<c;JM5hqD zGYtDwEJ8D4DF%%wXU82*ww+x%Z83D_XCn!B2xwi&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&)8bZI_kY0?D zElMNl^dM?U%1OBwbI020_j+rrb(9%yj7ur*Fq%vjKOHkAw*CzqY}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;{cuXlBzmmzI$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_7rignhhJxEFWRBH9P3w=}f~3R$&!7oJ<*KeTVt!aDg?iD zYfbI_$1tkgFdM3&DtlEdfvax*;%$VkUo`8@dIahbs7Ih4fqDe$5vWJt|1Sdn1vprt AKL7v#
literal 0
HcmV?d00001
Signature · 1 line
2.25.1
PATCH v2 1/3 logos: Add sunxi logo
Hi,
Quoted 9 lines · 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.bmpSigned-off-by Jagan Teki <[email protected]>
I'm not entirely sure what the benefit of that is to be honest.
U-boot has a logo, why not use it?
Maxime
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200618/5083d69d/attachment.sig>
PATCH v2 1/3 logos: Add sunxi logo
Quoted 8 lines · Maxime Ripard
Hi,
Quoted 5 lines · 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
Quoted 8 lines
Quoted 4 lines
$ convert sunxi.jpg -type Palette -colors 224 -depth 8 \ -compress none -verbose BMP3:tools/logos/sunxi.bmpSigned-off-by Jagan Teki <[email protected]>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.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200618/4a14ee51/attachment.sig>
PATCH v2 2/3 sunxi: Enable splash screen support
In reply to Jagan TekiEnable 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.
---
Changes for v2:
- new patch
include/configs/sunxi-common.h | 11 +++++++++++ 1 file changed, 11 insertions(+)
include/configs/sunxi-common.h +11 -0
@@ -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
Signature · 1 line
2.25.1
PATCH v2 3/3 video: sunxi_display: Convert to DM_VIDEO
In reply to Jagan TekiDM_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.
---
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(-)
arch/arm/mach-sunxi/Kconfig +3 -1
@@ -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
drivers/video/sunxi/sunxi_display.c +154 -110
577 lines not on this page · raw message
include/configs/sunxi-common.h +0 -17
@@ -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
scripts/config_whitelist.txt +0 -1
@@ -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
Signature · 1 line
2.25.1
PATCH v2 3/3 video: sunxi_display: Convert to DM_VIDEO
Quoted 66 lines · Jagan Teki
DM_VIDEOmigration 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_VIDEOPlease update the board to useCONFIG_DM_VIDEObefore the v2019.07 release. Failure to update by the deadline may result in board removal. Seedoc/driver-model/migration.rstfor 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 <[email protected]>---
Changes for v2:
- add BMP supportarch/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(-)arch/arm/mach-sunxi/Kconfig +3
-1@@ -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, LCDdrivers/video/sunxi/sunxi_display.c +4
-0@@ -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"
drivers/video/sunxi/sunxi_display.c line 57
Quoted 9 lines
drivers/video/sunxi/sunxi_display.c +6
-0@@ -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 , +};
Why is that an enum? Those three values don't have any relationship with each other.
Quoted 4 lines
drivers/video/sunxi/sunxi_display.c +0
-0enum sunxi_monitor { sunxi_monitor_none, sunxi_monitor_dvi,
drivers/video/sunxi/sunxi_display.c enum sunxi_monitor { · line 77
Quoted 10 lines
drivers/video/sunxi/sunxi_display.c +1
-2@@ -59,12 +70,11 @@ enum sunxi_monitor {#define SUNXI_MONITOR_LAST sunxi_monitor_composite_pal_ncstruct 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?
Quoted 247 lines
drivers/video/sunxi/sunxi_display.c +45
-38const 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 definedCONFIG_VIDEO_HDMI || definedCONFIG_VIDEO_VGA || definedCONFIG_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 definedCONFIG_VIDEO_VGA || definedCONFIG_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 definedCONFIG_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 ;
drivers/video/sunxi/sunxi_display.c static const char *sunxi_get_mon_desc(enum sunxi_monitor monitor) · line 1006
Quoted 8 lines
drivers/video/sunxi/sunxi_display.c +0
-5@@ -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 ; -} -
I couldn't find how you're allocating and reserving the video buffer now for simplefb to use later on.
Quoted 210 lines
drivers/video/sunxi/sunxi_display.c +42
-54static 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 ;
drivers/video/sunxi/sunxi_display.c void *video_hw_init(void) · line 1225
Quoted 10 lines
drivers/video/sunxi/sunxi_display.c +5
-5- 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 );
This is new. You should explain in a separate patch why the flush_cache above isn't enough.
Maxime
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200618/e35c4fff/attachment.sig>
PATCH v2 3/3 video: sunxi_display: Convert to DM_VIDEO
Quoted 71 lines · Maxime Ripard
Quoted 69 lines · Jagan Teki
DM_VIDEOmigration 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_VIDEOPlease update the board to useCONFIG_DM_VIDEObefore the v2019.07 release. Failure to update by the deadline may result in board removal. Seedoc/driver-model/migration.rstfor 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 <[email protected]>---
Changes for v2:
- add BMP supportarch/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(-)arch/arm/mach-sunxi/Kconfig +3
-1@@ -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, LCDdrivers/video/sunxi/sunxi_display.c +4
-0@@ -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 ;
Quoted 9 lines
drivers/video/sunxi/sunxi_display.c line 57
Quoted 6 lines
drivers/video/sunxi/sunxi_display.c +6
-0+enum { +/* Maximum LCD size we support */ +LCD_MAX_WIDTH =3840 , +LCD_MAX_HEIGHT =2160 , +LCD_MAX_LOG2_BPP =VIDEO_BPP32 , +};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.
Quoted 268 lines
Quoted 5 lines
drivers/video/sunxi/sunxi_display.c +0
-0enum sunxi_monitor { sunxi_monitor_none, sunxi_monitor_dvi,drivers/video/sunxi/sunxi_display.c enum sunxi_monitor { · line 77
Quoted 10 lines
drivers/video/sunxi/sunxi_display.c +1
-2@@ -59,12 +70,11 @@ enum sunxi_monitor {#define SUNXI_MONITOR_LAST sunxi_monitor_composite_pal_ncstruct 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?
Quoted 250 lines
drivers/video/sunxi/sunxi_display.c +45
-38const 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 definedCONFIG_VIDEO_HDMI || definedCONFIG_VIDEO_VGA || definedCONFIG_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 definedCONFIG_VIDEO_VGA || definedCONFIG_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 definedCONFIG_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) } }
Quoted 8 lines
drivers/video/sunxi/sunxi_display.c static const char *sunxi_get_mon_desc(enum sunxi_monitor monitor) · line 1006
Quoted 5 lines
drivers/video/sunxi/sunxi_display.c +0
-5-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.
Quoted 216 lines
Quoted 216 lines
drivers/video/sunxi/sunxi_display.c +42
-59static 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;
Quoted 8 lines
drivers/video/sunxi/sunxi_display.c void *video_hw_init(void) · line 1225
Quoted 5 lines
drivers/video/sunxi/sunxi_display.c +5
-0+ uc_priv->bpix =VIDEO_BPP32 ; + uc_priv->xsize = mode->xres; + uc_priv->ysize = mode->yres; + +video_set_flush_dcache (dev,1 );This is new. You should explain in a separate patch why the
flush_cacheabove 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.
PATCH v2 3/3 video: sunxi_display: Convert to DM_VIDEO
Hi
Quoted 364 lines · Jagan Teki
Quoted 71 lines · Maxime Ripard
Quoted 69 lines · Jagan Teki
DM_VIDEOmigration 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_VIDEOPlease update the board to useCONFIG_DM_VIDEObefore the v2019.07 release. Failure to update by the deadline may result in board removal. Seedoc/driver-model/migration.rstfor 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 <[email protected]>---
Changes for v2:
- add BMP supportarch/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(-)arch/arm/mach-sunxi/Kconfig +3
-1@@ -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, LCDdrivers/video/sunxi/sunxi_display.c +4
-0@@ -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 ;Quoted 9 lines
drivers/video/sunxi/sunxi_display.c line 57
Quoted 6 lines
drivers/video/sunxi/sunxi_display.c +6
-0+enum { +/* Maximum LCD size we support */ +LCD_MAX_WIDTH =3840 , +LCD_MAX_HEIGHT =2160 , +LCD_MAX_LOG2_BPP =VIDEO_BPP32 , +};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_bindon this patch.Quoted 268 lines
Quoted 5 lines
drivers/video/sunxi/sunxi_display.c +0
-0enum sunxi_monitor { sunxi_monitor_none, sunxi_monitor_dvi,drivers/video/sunxi/sunxi_display.c enum sunxi_monitor { · line 77
Quoted 10 lines
drivers/video/sunxi/sunxi_display.c +1
-2@@ -59,12 +70,11 @@ enum sunxi_monitor {#define SUNXI_MONITOR_LAST sunxi_monitor_composite_pal_ncstruct 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?
Quoted 250 lines
drivers/video/sunxi/sunxi_display.c +45
-38const 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 definedCONFIG_VIDEO_HDMI || definedCONFIG_VIDEO_VGA || definedCONFIG_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 definedCONFIG_VIDEO_VGA || definedCONFIG_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 definedCONFIG_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) } }Quoted 8 lines
drivers/video/sunxi/sunxi_display.c static const char *sunxi_get_mon_desc(enum sunxi_monitor monitor) · line 1006
Quoted 5 lines
drivers/video/sunxi/sunxi_display.c +0
-5-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.
Quoted 3 lines
Based on maximum supporting resolutions and bpp as explained above and similar like what
sunxi_de2and other platforms like rockchip. viaplat->size.
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
Quoted 234 lines
Quoted 217 lines
Quoted 217 lines
drivers/video/sunxi/sunxi_display.c +42
-59static 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;Quoted 8 lines
drivers/video/sunxi/sunxi_display.c void *video_hw_init(void) · line 1225
Quoted 5 lines
drivers/video/sunxi/sunxi_display.c +5
-0+ uc_priv->bpix =VIDEO_BPP32 ; + uc_priv->xsize = mode->xres; + uc_priv->ysize = mode->yres; + +video_set_flush_dcache (dev,1 );This is new. You should explain in a separate patch why the
flush_cacheabove isn't enough.This is new and but required when for
DM_VIDEOconversion. video-uclass has a common way to flush video viavideo_syncso the driver has to trigger this flush and without this, the vidconsole shows inconsistent characters.Jagan.
Signature · 4 lines
| Michael Nazzareno Trimarchi Amarula Solutions BV | | COO - Founder Cruquiuskade 47 | | +31(0)851119172 Amsterdam 1018 AM NL | | [`as] http://www.amarulasolutions.com |
PATCH v2 3/3 video: sunxi_display: Convert to DM_VIDEO
In reply to Jagan TekiQuoted 82 lines · Jagan Teki
Quoted 71 lines · Maxime Ripard
Quoted 69 lines · Jagan Teki
DM_VIDEOmigration 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_VIDEOPlease update the board to useCONFIG_DM_VIDEObefore the v2019.07 release. Failure to update by the deadline may result in board removal. Seedoc/driver-model/migration.rstfor 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 <[email protected]>---
Changes for v2:
- add BMP supportarch/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(-)arch/arm/mach-sunxi/Kconfig +3
-1@@ -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, LCDdrivers/video/sunxi/sunxi_display.c +4
-0@@ -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 ;Quoted 9 lines
drivers/video/sunxi/sunxi_display.c line 57
Quoted 6 lines
drivers/video/sunxi/sunxi_display.c +6
-0+enum { +/* Maximum LCD size we support */ +LCD_MAX_WIDTH =3840 , +LCD_MAX_HEIGHT =2160 , +LCD_MAX_LOG2_BPP =VIDEO_BPP32 , +};Why is that an enum? Those three values don't have any relationship with each other.
Quoted 3 lines
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_bindon this patch.
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.
Quoted 9 lines
Quoted 8 lines
drivers/video/sunxi/sunxi_display.c static const char *sunxi_get_mon_desc(enum sunxi_monitor monitor) · line 1006
Quoted 5 lines
drivers/video/sunxi/sunxi_display.c +0
-5-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.
Quoted 3 lines
Based on maximum supporting resolutions and bpp as explained above and similar like what
sunxi_de2and other platforms like rockchip. viaplat->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?
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.
Quoted 225 lines
Quoted 216 lines
Quoted 216 lines
static bool
sunxi_has_hdmi(void)
{
#ifdefCONFIG_VIDEO_HDMIdrivers/video/sunxi/sunxi_display.c +42
-59@@ -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;Quoted 8 lines
drivers/video/sunxi/sunxi_display.c void *video_hw_init(void) · line 1225
Quoted 5 lines
drivers/video/sunxi/sunxi_display.c +5
-0+ uc_priv->bpix =VIDEO_BPP32 ; + uc_priv->xsize = mode->xres; + uc_priv->ysize = mode->yres; + +video_set_flush_dcache (dev,1 );This is new. You should explain in a separate patch why the
flush_cacheabove isn't enough.
Quoted 4 lines
This is new and but required when for
DM_VIDEOconversion. video-uclass has a common way to flush video viavideo_syncso the driver has to trigger this flush and without this, the vidconsole shows inconsistent characters.
I still believe this is redundant with the flush_cache above.
Maxime
PATCH v2 3/3 video: sunxi_display: Convert to DM_VIDEO
On Fri, 19 Jun 2020 09:30:22 +0200
Maxime Ripard <[email protected]> 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:
Quoted 83 lines · Jagan Teki
Quoted 82 lines · Maxime Ripard
Quoted 80 lines · Jagan Teki
Quoted 66 lines
DM_VIDEOmigration 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_VIDEOPlease update the board to useCONFIG_DM_VIDEObefore the v2019.07 release. Failure to update by the deadline may result in board removal. Seedoc/driver-model/migration.rstfor 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 <[email protected]>---
Changes for v2:
- add BMP supportarch/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(-)arch/arm/mach-sunxi/Kconfig +3
-1@@ -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, LCDdrivers/video/sunxi/sunxi_display.c +4
-0@@ -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" drivers/video/sunxi/sunxi_display.c line 57
Quoted 9 lines
drivers/video/sunxi/sunxi_display.c +6
-0@@ -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 , +};Why is that an enum? Those three values don't have any relationship with each other.
Quoted 8 lines
Quoted 3 lines
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_bindon this patch.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.
Quoted 22 lines
Quoted 10 lines
Quoted 9 lines
drivers/video/sunxi/sunxi_display.c static const char *sunxi_get_mon_desc(enum sunxi_monitor monitor) · line 1006
Quoted 6 lines
drivers/video/sunxi/sunxi_display.c +0
-5-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.
Quoted 3 lines
Based on maximum supporting resolutions and bpp as explained above and similar like what
sunxi_de2and other platforms like rockchip. viaplat->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?
Quoted 4 lines
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.
Quoted 228 lines
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.
Quoted 225 lines
Quoted 224 lines
Quoted 211 lines
static bool
sunxi_has_hdmi(void)
{
#ifdefCONFIG_VIDEO_HDMIdrivers/video/sunxi/sunxi_display.c +42
-54@@ -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 ;drivers/video/sunxi/sunxi_display.c void *video_hw_init(void) · line 1225
Quoted 10 lines
drivers/video/sunxi/sunxi_display.c +5
-5- 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 );This is new. You should explain in a separate patch why the
flush_cacheabove isn't enough.
Quoted 6 lines
Quoted 4 lines
This is new and but required when for
DM_VIDEOconversion. video-uclass has a common way to flush video viavideo_syncso the driver has to trigger this flush and without this, the vidconsole shows inconsistent characters.I still believe this is redundant with the
flush_cacheabove.
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