12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405 |
- From 3efc90a6ea3bb88b66af7f7096e8168c2cc34aa6 Mon Sep 17 00:00:00 2001
- From: Alper Nebi Yasak <alpernebiyasak@gmail.com>
- Date: Fri, 18 Aug 2023 13:31:36 +0300
- Subject: [PATCH 01/13] video: test: Split copy frame buffer check into a
- function
- While checking frame buffer contents, the video tests also check if the
- copy frame buffer contents match the main frame buffer. To test if only
- the modified regions are updated after a sync, we will need to create
- situations where the two are mismatched. Split this check into another
- function that we can skip calling, since we won't want it to error on
- those mismatched cases.
- Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
- Reviewed-by: Simon Glass <sjg@chromium.org>
- Link: https://lore.kernel.org/u-boot/20230821135111.3558478-2-alpernebiyasak@gmail.com/
- ---
- test/dm/video.c | 69 +++++++++++++++++++++++++++++++++++++++++--------
- 1 file changed, 58 insertions(+), 11 deletions(-)
- diff --git a/test/dm/video.c b/test/dm/video.c
- index 7dfbeb9555d1..14e6af5181f1 100644
- --- a/test/dm/video.c
- +++ b/test/dm/video.c
- @@ -54,9 +54,6 @@ DM_TEST(dm_test_video_base, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
- * size of the compressed data. This provides a pretty good level of
- * certainty and the resulting tests need only check a single value.
- *
- - * If the copy framebuffer is enabled, this compares it to the main framebuffer
- - * too.
- - *
- * @uts: Test state
- * @dev: Video device
- * Return: compressed size of the frame buffer, or -ve on error
- @@ -65,7 +62,6 @@ static int compress_frame_buffer(struct unit_test_state *uts,
- struct udevice *dev)
- {
- struct video_priv *priv = dev_get_uclass_priv(dev);
- - struct video_priv *uc_priv = dev_get_uclass_priv(dev);
- uint destlen;
- void *dest;
- int ret;
- @@ -81,16 +77,34 @@ static int compress_frame_buffer(struct unit_test_state *uts,
- if (ret)
- return ret;
-
- - /* Check here that the copy frame buffer is working correctly */
- - if (IS_ENABLED(CONFIG_VIDEO_COPY)) {
- - ut_assertf(!memcmp(uc_priv->fb, uc_priv->copy_fb,
- - uc_priv->fb_size),
- - "Copy framebuffer does not match fb");
- - }
- -
- return destlen;
- }
-
- +/**
- + * check_copy_frame_buffer() - Compare main frame buffer to copy
- + *
- + * If the copy frame buffer is enabled, this compares it to the main
- + * frame buffer. Normally they should have the same contents after a
- + * sync.
- + *
- + * @uts: Test state
- + * @dev: Video device
- + * Return: 0, or -ve on error
- + */
- +static int check_copy_frame_buffer(struct unit_test_state *uts,
- + struct udevice *dev)
- +{
- + struct video_priv *priv = dev_get_uclass_priv(dev);
- +
- + if (!IS_ENABLED(CONFIG_VIDEO_COPY))
- + return 0;
- +
- + ut_assertf(!memcmp(priv->fb, priv->copy_fb, priv->fb_size),
- + "Copy framebuffer does not match fb");
- +
- + return 0;
- +}
- +
- /*
- * Call this function at any point to halt and show the current display. Be
- * sure to run the test with the -l flag.
- @@ -154,24 +168,30 @@ static int dm_test_video_text(struct unit_test_state *uts)
- ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
- ut_assertok(vidconsole_select_font(con, "8x16", 0));
- ut_asserteq(46, compress_frame_buffer(uts, dev));
- + ut_assertok(check_copy_frame_buffer(uts, dev));
-
- ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
- vidconsole_putc_xy(con, 0, 0, 'a');
- ut_asserteq(79, compress_frame_buffer(uts, dev));
- + ut_assertok(check_copy_frame_buffer(uts, dev));
-
- vidconsole_putc_xy(con, 0, 0, ' ');
- ut_asserteq(46, compress_frame_buffer(uts, dev));
- + ut_assertok(check_copy_frame_buffer(uts, dev));
-
- for (i = 0; i < 20; i++)
- vidconsole_putc_xy(con, VID_TO_POS(i * 8), 0, ' ' + i);
- ut_asserteq(273, compress_frame_buffer(uts, dev));
- + ut_assertok(check_copy_frame_buffer(uts, dev));
-
- vidconsole_set_row(con, 0, WHITE);
- ut_asserteq(46, compress_frame_buffer(uts, dev));
- + ut_assertok(check_copy_frame_buffer(uts, dev));
-
- for (i = 0; i < 20; i++)
- vidconsole_putc_xy(con, VID_TO_POS(i * 8), 0, ' ' + i);
- ut_asserteq(273, compress_frame_buffer(uts, dev));
- + ut_assertok(check_copy_frame_buffer(uts, dev));
-
- return 0;
- }
- @@ -190,24 +210,30 @@ static int dm_test_video_text_12x22(struct unit_test_state *uts)
- ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
- ut_assertok(vidconsole_select_font(con, "12x22", 0));
- ut_asserteq(46, compress_frame_buffer(uts, dev));
- + ut_assertok(check_copy_frame_buffer(uts, dev));
-
- ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
- vidconsole_putc_xy(con, 0, 0, 'a');
- ut_asserteq(89, compress_frame_buffer(uts, dev));
- + ut_assertok(check_copy_frame_buffer(uts, dev));
-
- vidconsole_putc_xy(con, 0, 0, ' ');
- ut_asserteq(46, compress_frame_buffer(uts, dev));
- + ut_assertok(check_copy_frame_buffer(uts, dev));
-
- for (i = 0; i < 20; i++)
- vidconsole_putc_xy(con, VID_TO_POS(i * 8), 0, ' ' + i);
- ut_asserteq(363, compress_frame_buffer(uts, dev));
- + ut_assertok(check_copy_frame_buffer(uts, dev));
-
- vidconsole_set_row(con, 0, WHITE);
- ut_asserteq(46, compress_frame_buffer(uts, dev));
- + ut_assertok(check_copy_frame_buffer(uts, dev));
-
- for (i = 0; i < 20; i++)
- vidconsole_putc_xy(con, VID_TO_POS(i * 8), 0, ' ' + i);
- ut_asserteq(363, compress_frame_buffer(uts, dev));
- + ut_assertok(check_copy_frame_buffer(uts, dev));
-
- return 0;
- }
- @@ -225,6 +251,7 @@ static int dm_test_video_chars(struct unit_test_state *uts)
- ut_assertok(vidconsole_select_font(con, "8x16", 0));
- vidconsole_put_string(con, test_string);
- ut_asserteq(466, compress_frame_buffer(uts, dev));
- + ut_assertok(check_copy_frame_buffer(uts, dev));
-
- return 0;
- }
- @@ -246,19 +273,23 @@ static int dm_test_video_ansi(struct unit_test_state *uts)
- video_clear(con->parent);
- video_sync(con->parent, false);
- ut_asserteq(46, compress_frame_buffer(uts, dev));
- + ut_assertok(check_copy_frame_buffer(uts, dev));
-
- /* test clear escape sequence: [2J */
- vidconsole_put_string(con, "A\tB\tC"ANSI_ESC"[2J");
- ut_asserteq(46, compress_frame_buffer(uts, dev));
- + ut_assertok(check_copy_frame_buffer(uts, dev));
-
- /* test set-cursor: [%d;%df */
- vidconsole_put_string(con, "abc"ANSI_ESC"[2;2fab"ANSI_ESC"[4;4fcd");
- ut_asserteq(143, compress_frame_buffer(uts, dev));
- + ut_assertok(check_copy_frame_buffer(uts, dev));
-
- /* test colors (30-37 fg color, 40-47 bg color) */
- vidconsole_put_string(con, ANSI_ESC"[30;41mfoo"); /* black on red */
- vidconsole_put_string(con, ANSI_ESC"[33;44mbar"); /* yellow on blue */
- ut_asserteq(272, compress_frame_buffer(uts, dev));
- + ut_assertok(check_copy_frame_buffer(uts, dev));
-
- return 0;
- }
- @@ -291,11 +322,13 @@ static int check_vidconsole_output(struct unit_test_state *uts, int rot,
- ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
- ut_assertok(vidconsole_select_font(con, "8x16", 0));
- ut_asserteq(46, compress_frame_buffer(uts, dev));
- + ut_assertok(check_copy_frame_buffer(uts, dev));
-
- /* Check display wrap */
- for (i = 0; i < 120; i++)
- vidconsole_put_char(con, 'A' + i % 50);
- ut_asserteq(wrap_size, compress_frame_buffer(uts, dev));
- + ut_assertok(check_copy_frame_buffer(uts, dev));
-
- /* Check display scrolling */
- for (i = 0; i < SCROLL_LINES; i++) {
- @@ -303,11 +336,13 @@ static int check_vidconsole_output(struct unit_test_state *uts, int rot,
- vidconsole_put_char(con, '\n');
- }
- ut_asserteq(scroll_size, compress_frame_buffer(uts, dev));
- + ut_assertok(check_copy_frame_buffer(uts, dev));
-
- /* If we scroll enough, the screen becomes blank again */
- for (i = 0; i < SCROLL_LINES; i++)
- vidconsole_put_char(con, '\n');
- ut_asserteq(46, compress_frame_buffer(uts, dev));
- + ut_assertok(check_copy_frame_buffer(uts, dev));
-
- return 0;
- }
- @@ -382,6 +417,7 @@ static int dm_test_video_bmp(struct unit_test_state *uts)
-
- ut_assertok(video_bmp_display(dev, addr, 0, 0, false));
- ut_asserteq(1368, compress_frame_buffer(uts, dev));
- + ut_assertok(check_copy_frame_buffer(uts, dev));
-
- return 0;
- }
- @@ -401,6 +437,7 @@ static int dm_test_video_bmp8(struct unit_test_state *uts)
-
- ut_assertok(video_bmp_display(dev, addr, 0, 0, false));
- ut_asserteq(1247, compress_frame_buffer(uts, dev));
- + ut_assertok(check_copy_frame_buffer(uts, dev));
-
- return 0;
- }
- @@ -424,6 +461,7 @@ static int dm_test_video_bmp16(struct unit_test_state *uts)
-
- ut_assertok(video_bmp_display(dev, dst, 0, 0, false));
- ut_asserteq(3700, compress_frame_buffer(uts, dev));
- + ut_assertok(check_copy_frame_buffer(uts, dev));
-
- return 0;
- }
- @@ -447,6 +485,7 @@ static int dm_test_video_bmp24(struct unit_test_state *uts)
-
- ut_assertok(video_bmp_display(dev, dst, 0, 0, false));
- ut_asserteq(3656, compress_frame_buffer(uts, dev));
- + ut_assertok(check_copy_frame_buffer(uts, dev));
-
- return 0;
- }
- @@ -470,6 +509,7 @@ static int dm_test_video_bmp24_32(struct unit_test_state *uts)
-
- ut_assertok(video_bmp_display(dev, dst, 0, 0, false));
- ut_asserteq(6827, compress_frame_buffer(uts, dev));
- + ut_assertok(check_copy_frame_buffer(uts, dev));
-
- return 0;
- }
- @@ -488,6 +528,7 @@ static int dm_test_video_bmp32(struct unit_test_state *uts)
-
- ut_assertok(video_bmp_display(dev, addr, 0, 0, false));
- ut_asserteq(2024, compress_frame_buffer(uts, dev));
- + ut_assertok(check_copy_frame_buffer(uts, dev));
-
- return 0;
- }
- @@ -504,6 +545,7 @@ static int dm_test_video_bmp_comp(struct unit_test_state *uts)
-
- ut_assertok(video_bmp_display(dev, addr, 0, 0, false));
- ut_asserteq(1368, compress_frame_buffer(uts, dev));
- + ut_assertok(check_copy_frame_buffer(uts, dev));
-
- return 0;
- }
- @@ -523,6 +565,7 @@ static int dm_test_video_comp_bmp32(struct unit_test_state *uts)
-
- ut_assertok(video_bmp_display(dev, addr, 0, 0, false));
- ut_asserteq(2024, compress_frame_buffer(uts, dev));
- + ut_assertok(check_copy_frame_buffer(uts, dev));
-
- return 0;
- }
- @@ -542,6 +585,7 @@ static int dm_test_video_comp_bmp8(struct unit_test_state *uts)
-
- ut_assertok(video_bmp_display(dev, addr, 0, 0, false));
- ut_asserteq(1247, compress_frame_buffer(uts, dev));
- + ut_assertok(check_copy_frame_buffer(uts, dev));
-
- return 0;
- }
- @@ -557,6 +601,7 @@ static int dm_test_video_truetype(struct unit_test_state *uts)
- ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
- vidconsole_put_string(con, test_string);
- ut_asserteq(12174, compress_frame_buffer(uts, dev));
- + ut_assertok(check_copy_frame_buffer(uts, dev));
-
- return 0;
- }
- @@ -578,6 +623,7 @@ static int dm_test_video_truetype_scroll(struct unit_test_state *uts)
- ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
- vidconsole_put_string(con, test_string);
- ut_asserteq(34287, compress_frame_buffer(uts, dev));
- + ut_assertok(check_copy_frame_buffer(uts, dev));
-
- return 0;
- }
- @@ -599,6 +645,7 @@ static int dm_test_video_truetype_bs(struct unit_test_state *uts)
- ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
- vidconsole_put_string(con, test_string);
- ut_asserteq(29471, compress_frame_buffer(uts, dev));
- + ut_assertok(check_copy_frame_buffer(uts, dev));
-
- return 0;
- }
- base-commit: 475aa8345a78396d39b42f96eccecd37ebe24e99
- --
- 2.45.2
- From 19c878635c1271c79a017ea3a860b9a2f1a3fed9 Mon Sep 17 00:00:00 2001
- From: Alper Nebi Yasak <alpernebiyasak@gmail.com>
- Date: Sun, 20 Aug 2023 17:46:46 +0300
- Subject: [PATCH 02/13] video: test: Support checking copy frame buffer
- contents
- The video tests have a helper function to generate a pseudo-digest of
- frame buffer contents, but it only does so for the main one. There is
- another check that the copy frame buffer is the same as that. But
- neither is enough to test if only the modified regions are copied to the
- copy frame buffer, since we will want the two to be different in very
- specific ways.
- Add a boolean argument to the existing helper function to indicate which
- frame buffer we want to inspect, and update the existing callers.
- Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
- Reviewed-by: Simon Glass <sjg@chromium.org>
- Link: https://lore.kernel.org/u-boot/20230821135111.3558478-3-alpernebiyasak@gmail.com/
- ---
- test/dm/video.c | 76 ++++++++++++++++++++++++++-----------------------
- 1 file changed, 41 insertions(+), 35 deletions(-)
- diff --git a/test/dm/video.c b/test/dm/video.c
- index 14e6af5181f1..50374cafc009 100644
- --- a/test/dm/video.c
- +++ b/test/dm/video.c
- @@ -56,22 +56,28 @@ DM_TEST(dm_test_video_base, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
- *
- * @uts: Test state
- * @dev: Video device
- + * @use_copy: Use copy frame buffer if available
- * Return: compressed size of the frame buffer, or -ve on error
- */
- static int compress_frame_buffer(struct unit_test_state *uts,
- - struct udevice *dev)
- + struct udevice *dev,
- + bool use_copy)
- {
- struct video_priv *priv = dev_get_uclass_priv(dev);
- uint destlen;
- void *dest;
- int ret;
-
- + if (!IS_ENABLED(CONFIG_VIDEO_COPY))
- + use_copy = false;
- +
- destlen = priv->fb_size;
- dest = malloc(priv->fb_size);
- if (!dest)
- return -ENOMEM;
- ret = BZ2_bzBuffToBuffCompress(dest, &destlen,
- - priv->fb, priv->fb_size,
- + use_copy ? priv->copy_fb : priv->fb,
- + priv->fb_size,
- 3, 0, 0);
- free(dest);
- if (ret)
- @@ -167,30 +173,30 @@ static int dm_test_video_text(struct unit_test_state *uts)
- ut_assertok(video_get_nologo(uts, &dev));
- ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
- ut_assertok(vidconsole_select_font(con, "8x16", 0));
- - ut_asserteq(46, compress_frame_buffer(uts, dev));
- + ut_asserteq(46, compress_frame_buffer(uts, dev, false));
- ut_assertok(check_copy_frame_buffer(uts, dev));
-
- ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
- vidconsole_putc_xy(con, 0, 0, 'a');
- - ut_asserteq(79, compress_frame_buffer(uts, dev));
- + ut_asserteq(79, compress_frame_buffer(uts, dev, false));
- ut_assertok(check_copy_frame_buffer(uts, dev));
-
- vidconsole_putc_xy(con, 0, 0, ' ');
- - ut_asserteq(46, compress_frame_buffer(uts, dev));
- + ut_asserteq(46, compress_frame_buffer(uts, dev, false));
- ut_assertok(check_copy_frame_buffer(uts, dev));
-
- for (i = 0; i < 20; i++)
- vidconsole_putc_xy(con, VID_TO_POS(i * 8), 0, ' ' + i);
- - ut_asserteq(273, compress_frame_buffer(uts, dev));
- + ut_asserteq(273, compress_frame_buffer(uts, dev, false));
- ut_assertok(check_copy_frame_buffer(uts, dev));
-
- vidconsole_set_row(con, 0, WHITE);
- - ut_asserteq(46, compress_frame_buffer(uts, dev));
- + ut_asserteq(46, compress_frame_buffer(uts, dev, false));
- ut_assertok(check_copy_frame_buffer(uts, dev));
-
- for (i = 0; i < 20; i++)
- vidconsole_putc_xy(con, VID_TO_POS(i * 8), 0, ' ' + i);
- - ut_asserteq(273, compress_frame_buffer(uts, dev));
- + ut_asserteq(273, compress_frame_buffer(uts, dev, false));
- ut_assertok(check_copy_frame_buffer(uts, dev));
-
- return 0;
- @@ -209,30 +215,30 @@ static int dm_test_video_text_12x22(struct unit_test_state *uts)
- ut_assertok(video_get_nologo(uts, &dev));
- ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
- ut_assertok(vidconsole_select_font(con, "12x22", 0));
- - ut_asserteq(46, compress_frame_buffer(uts, dev));
- + ut_asserteq(46, compress_frame_buffer(uts, dev, false));
- ut_assertok(check_copy_frame_buffer(uts, dev));
-
- ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
- vidconsole_putc_xy(con, 0, 0, 'a');
- - ut_asserteq(89, compress_frame_buffer(uts, dev));
- + ut_asserteq(89, compress_frame_buffer(uts, dev, false));
- ut_assertok(check_copy_frame_buffer(uts, dev));
-
- vidconsole_putc_xy(con, 0, 0, ' ');
- - ut_asserteq(46, compress_frame_buffer(uts, dev));
- + ut_asserteq(46, compress_frame_buffer(uts, dev, false));
- ut_assertok(check_copy_frame_buffer(uts, dev));
-
- for (i = 0; i < 20; i++)
- vidconsole_putc_xy(con, VID_TO_POS(i * 8), 0, ' ' + i);
- - ut_asserteq(363, compress_frame_buffer(uts, dev));
- + ut_asserteq(363, compress_frame_buffer(uts, dev, false));
- ut_assertok(check_copy_frame_buffer(uts, dev));
-
- vidconsole_set_row(con, 0, WHITE);
- - ut_asserteq(46, compress_frame_buffer(uts, dev));
- + ut_asserteq(46, compress_frame_buffer(uts, dev, false));
- ut_assertok(check_copy_frame_buffer(uts, dev));
-
- for (i = 0; i < 20; i++)
- vidconsole_putc_xy(con, VID_TO_POS(i * 8), 0, ' ' + i);
- - ut_asserteq(363, compress_frame_buffer(uts, dev));
- + ut_asserteq(363, compress_frame_buffer(uts, dev, false));
- ut_assertok(check_copy_frame_buffer(uts, dev));
-
- return 0;
- @@ -250,7 +256,7 @@ static int dm_test_video_chars(struct unit_test_state *uts)
- ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
- ut_assertok(vidconsole_select_font(con, "8x16", 0));
- vidconsole_put_string(con, test_string);
- - ut_asserteq(466, compress_frame_buffer(uts, dev));
- + ut_asserteq(466, compress_frame_buffer(uts, dev, false));
- ut_assertok(check_copy_frame_buffer(uts, dev));
-
- return 0;
- @@ -272,23 +278,23 @@ static int dm_test_video_ansi(struct unit_test_state *uts)
- /* reference clear: */
- video_clear(con->parent);
- video_sync(con->parent, false);
- - ut_asserteq(46, compress_frame_buffer(uts, dev));
- + ut_asserteq(46, compress_frame_buffer(uts, dev, false));
- ut_assertok(check_copy_frame_buffer(uts, dev));
-
- /* test clear escape sequence: [2J */
- vidconsole_put_string(con, "A\tB\tC"ANSI_ESC"[2J");
- - ut_asserteq(46, compress_frame_buffer(uts, dev));
- + ut_asserteq(46, compress_frame_buffer(uts, dev, false));
- ut_assertok(check_copy_frame_buffer(uts, dev));
-
- /* test set-cursor: [%d;%df */
- vidconsole_put_string(con, "abc"ANSI_ESC"[2;2fab"ANSI_ESC"[4;4fcd");
- - ut_asserteq(143, compress_frame_buffer(uts, dev));
- + ut_asserteq(143, compress_frame_buffer(uts, dev, false));
- ut_assertok(check_copy_frame_buffer(uts, dev));
-
- /* test colors (30-37 fg color, 40-47 bg color) */
- vidconsole_put_string(con, ANSI_ESC"[30;41mfoo"); /* black on red */
- vidconsole_put_string(con, ANSI_ESC"[33;44mbar"); /* yellow on blue */
- - ut_asserteq(272, compress_frame_buffer(uts, dev));
- + ut_asserteq(272, compress_frame_buffer(uts, dev, false));
- ut_assertok(check_copy_frame_buffer(uts, dev));
-
- return 0;
- @@ -321,13 +327,13 @@ static int check_vidconsole_output(struct unit_test_state *uts, int rot,
- ut_assertok(video_get_nologo(uts, &dev));
- ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
- ut_assertok(vidconsole_select_font(con, "8x16", 0));
- - ut_asserteq(46, compress_frame_buffer(uts, dev));
- + ut_asserteq(46, compress_frame_buffer(uts, dev, false));
- ut_assertok(check_copy_frame_buffer(uts, dev));
-
- /* Check display wrap */
- for (i = 0; i < 120; i++)
- vidconsole_put_char(con, 'A' + i % 50);
- - ut_asserteq(wrap_size, compress_frame_buffer(uts, dev));
- + ut_asserteq(wrap_size, compress_frame_buffer(uts, dev, false));
- ut_assertok(check_copy_frame_buffer(uts, dev));
-
- /* Check display scrolling */
- @@ -335,13 +341,13 @@ static int check_vidconsole_output(struct unit_test_state *uts, int rot,
- vidconsole_put_char(con, 'A' + i % 50);
- vidconsole_put_char(con, '\n');
- }
- - ut_asserteq(scroll_size, compress_frame_buffer(uts, dev));
- + ut_asserteq(scroll_size, compress_frame_buffer(uts, dev, false));
- ut_assertok(check_copy_frame_buffer(uts, dev));
-
- /* If we scroll enough, the screen becomes blank again */
- for (i = 0; i < SCROLL_LINES; i++)
- vidconsole_put_char(con, '\n');
- - ut_asserteq(46, compress_frame_buffer(uts, dev));
- + ut_asserteq(46, compress_frame_buffer(uts, dev, false));
- ut_assertok(check_copy_frame_buffer(uts, dev));
-
- return 0;
- @@ -416,7 +422,7 @@ static int dm_test_video_bmp(struct unit_test_state *uts)
- ut_assertok(read_file(uts, "tools/logos/denx.bmp", &addr));
-
- ut_assertok(video_bmp_display(dev, addr, 0, 0, false));
- - ut_asserteq(1368, compress_frame_buffer(uts, dev));
- + ut_asserteq(1368, compress_frame_buffer(uts, dev, false));
- ut_assertok(check_copy_frame_buffer(uts, dev));
-
- return 0;
- @@ -436,7 +442,7 @@ static int dm_test_video_bmp8(struct unit_test_state *uts)
- ut_assertok(read_file(uts, "tools/logos/denx.bmp", &addr));
-
- ut_assertok(video_bmp_display(dev, addr, 0, 0, false));
- - ut_asserteq(1247, compress_frame_buffer(uts, dev));
- + ut_asserteq(1247, compress_frame_buffer(uts, dev, false));
- ut_assertok(check_copy_frame_buffer(uts, dev));
-
- return 0;
- @@ -460,7 +466,7 @@ static int dm_test_video_bmp16(struct unit_test_state *uts)
- &src_len));
-
- ut_assertok(video_bmp_display(dev, dst, 0, 0, false));
- - ut_asserteq(3700, compress_frame_buffer(uts, dev));
- + ut_asserteq(3700, compress_frame_buffer(uts, dev, false));
- ut_assertok(check_copy_frame_buffer(uts, dev));
-
- return 0;
- @@ -484,7 +490,7 @@ static int dm_test_video_bmp24(struct unit_test_state *uts)
- &src_len));
-
- ut_assertok(video_bmp_display(dev, dst, 0, 0, false));
- - ut_asserteq(3656, compress_frame_buffer(uts, dev));
- + ut_asserteq(3656, compress_frame_buffer(uts, dev, false));
- ut_assertok(check_copy_frame_buffer(uts, dev));
-
- return 0;
- @@ -508,7 +514,7 @@ static int dm_test_video_bmp24_32(struct unit_test_state *uts)
- &src_len));
-
- ut_assertok(video_bmp_display(dev, dst, 0, 0, false));
- - ut_asserteq(6827, compress_frame_buffer(uts, dev));
- + ut_asserteq(6827, compress_frame_buffer(uts, dev, false));
- ut_assertok(check_copy_frame_buffer(uts, dev));
-
- return 0;
- @@ -527,7 +533,7 @@ static int dm_test_video_bmp32(struct unit_test_state *uts)
- ut_assertok(read_file(uts, "tools/logos/denx.bmp", &addr));
-
- ut_assertok(video_bmp_display(dev, addr, 0, 0, false));
- - ut_asserteq(2024, compress_frame_buffer(uts, dev));
- + ut_asserteq(2024, compress_frame_buffer(uts, dev, false));
- ut_assertok(check_copy_frame_buffer(uts, dev));
-
- return 0;
- @@ -544,7 +550,7 @@ static int dm_test_video_bmp_comp(struct unit_test_state *uts)
- ut_assertok(read_file(uts, "tools/logos/denx-comp.bmp", &addr));
-
- ut_assertok(video_bmp_display(dev, addr, 0, 0, false));
- - ut_asserteq(1368, compress_frame_buffer(uts, dev));
- + ut_asserteq(1368, compress_frame_buffer(uts, dev, false));
- ut_assertok(check_copy_frame_buffer(uts, dev));
-
- return 0;
- @@ -564,7 +570,7 @@ static int dm_test_video_comp_bmp32(struct unit_test_state *uts)
- ut_assertok(read_file(uts, "tools/logos/denx.bmp", &addr));
-
- ut_assertok(video_bmp_display(dev, addr, 0, 0, false));
- - ut_asserteq(2024, compress_frame_buffer(uts, dev));
- + ut_asserteq(2024, compress_frame_buffer(uts, dev, false));
- ut_assertok(check_copy_frame_buffer(uts, dev));
-
- return 0;
- @@ -584,7 +590,7 @@ static int dm_test_video_comp_bmp8(struct unit_test_state *uts)
- ut_assertok(read_file(uts, "tools/logos/denx.bmp", &addr));
-
- ut_assertok(video_bmp_display(dev, addr, 0, 0, false));
- - ut_asserteq(1247, compress_frame_buffer(uts, dev));
- + ut_asserteq(1247, compress_frame_buffer(uts, dev, false));
- ut_assertok(check_copy_frame_buffer(uts, dev));
-
- return 0;
- @@ -600,7 +606,7 @@ static int dm_test_video_truetype(struct unit_test_state *uts)
- ut_assertok(video_get_nologo(uts, &dev));
- ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
- vidconsole_put_string(con, test_string);
- - ut_asserteq(12174, compress_frame_buffer(uts, dev));
- + ut_asserteq(12174, compress_frame_buffer(uts, dev, false));
- ut_assertok(check_copy_frame_buffer(uts, dev));
-
- return 0;
- @@ -622,7 +628,7 @@ static int dm_test_video_truetype_scroll(struct unit_test_state *uts)
- ut_assertok(video_get_nologo(uts, &dev));
- ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
- vidconsole_put_string(con, test_string);
- - ut_asserteq(34287, compress_frame_buffer(uts, dev));
- + ut_asserteq(34287, compress_frame_buffer(uts, dev, false));
- ut_assertok(check_copy_frame_buffer(uts, dev));
-
- return 0;
- @@ -644,7 +650,7 @@ static int dm_test_video_truetype_bs(struct unit_test_state *uts)
- ut_assertok(video_get_nologo(uts, &dev));
- ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
- vidconsole_put_string(con, test_string);
- - ut_asserteq(29471, compress_frame_buffer(uts, dev));
- + ut_asserteq(29471, compress_frame_buffer(uts, dev, false));
- ut_assertok(check_copy_frame_buffer(uts, dev));
-
- return 0;
- --
- 2.45.2
- From 173f97f38d1c6621acd9f24f8956c3a7d808cdd7 Mon Sep 17 00:00:00 2001
- From: Alper Nebi Yasak <alpernebiyasak@gmail.com>
- Date: Fri, 18 Aug 2023 17:31:27 +0300
- Subject: [PATCH 03/13] video: test: Test partial updates of hardware frame
- buffer
- With VIDEO_COPY enabled, only the modified parts of the frame buffer are
- intended to be copied to the hardware. Add a test that checks this, by
- overwriting contents we prepared without telling the video uclass and
- then checking if the overwritten contents have been redrawn on the next
- sync.
- Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
- Reviewed-by: Simon Glass <sjg@chromium.org>
- Link: https://lore.kernel.org/u-boot/20230821135111.3558478-4-alpernebiyasak@gmail.com/
- ---
- test/dm/video.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++
- 1 file changed, 54 insertions(+)
- diff --git a/test/dm/video.c b/test/dm/video.c
- index 50374cafc009..4798f2205a99 100644
- --- a/test/dm/video.c
- +++ b/test/dm/video.c
- @@ -656,3 +656,57 @@ static int dm_test_video_truetype_bs(struct unit_test_state *uts)
- return 0;
- }
- DM_TEST(dm_test_video_truetype_bs, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
- +
- +/* Test partial rendering onto hardware frame buffer */
- +static int dm_test_video_copy(struct unit_test_state *uts)
- +{
- + struct sandbox_sdl_plat *plat;
- + struct video_uc_plat *uc_plat;
- + struct udevice *dev, *con;
- + struct video_priv *priv;
- + const char *test_string = "\n\tCriticism may not be agreeable, but it is necessary.\t";
- + ulong addr;
- +
- + if (!IS_ENABLED(CONFIG_VIDEO_COPY))
- + return -EAGAIN;
- +
- + ut_assertok(uclass_find_first_device(UCLASS_VIDEO, &dev));
- + ut_assertnonnull(dev);
- + uc_plat = dev_get_uclass_plat(dev);
- + uc_plat->hide_logo = true;
- + plat = dev_get_plat(dev);
- + plat->font_size = 32;
- + ut_assert(!device_active(dev));
- + ut_assertok(uclass_first_device_err(UCLASS_VIDEO, &dev));
- + ut_assertnonnull(dev);
- + priv = dev_get_uclass_priv(dev);
- +
- + ut_assertok(read_file(uts, "tools/logos/denx.bmp", &addr));
- + ut_assertok(video_bmp_display(dev, addr, 0, 0, false));
- +
- + ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
- + vidconsole_put_string(con, "\n\n\n\n\n");
- + vidconsole_put_string(con, test_string);
- + vidconsole_put_string(con, test_string);
- +
- + ut_asserteq(6678, compress_frame_buffer(uts, dev, false));
- + ut_assertok(check_copy_frame_buffer(uts, dev));
- +
- + /*
- + * Secretly clear the hardware frame buffer, but in a different
- + * color (black) to see which parts will be overwritten.
- + */
- + memset(priv->copy_fb, 0, priv->fb_size);
- +
- + /*
- + * We should have the full content on the main buffer, but only
- + * the new content should have been copied to the copy buffer.
- + */
- + vidconsole_put_string(con, test_string);
- + vidconsole_put_string(con, test_string);
- + ut_asserteq(7589, compress_frame_buffer(uts, dev, false));
- + ut_asserteq(5278, compress_frame_buffer(uts, dev, true));
- +
- + return 0;
- +}
- +DM_TEST(dm_test_video_copy, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
- --
- 2.45.2
- From 11066af4f8d7a9c6b4729ce2647eb6251397423d Mon Sep 17 00:00:00 2001
- From: Alexander Graf <agraf@csgraf.de>
- Date: Fri, 10 Jun 2022 00:59:15 +0200
- Subject: [PATCH 04/13] dm: video: Add damage tracking API
- We are going to introduce image damage tracking to fasten up screen
- refresh on large displays. This patch adds damage tracking for up to
- one rectangle of the screen which is typically enough to hold blt or
- text print updates. Callers into this API and a reduced dcache flush
- code path will follow in later patches.
- Signed-off-by: Alexander Graf <agraf@csgraf.de>
- Reported-by: Da Xue <da@libre.computer>
- [Alper: Use xstart/yend, document new fields, return void from
- video_damage(), declare priv, drop headers, use IS_ENABLED()]
- Co-developed-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
- Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
- Link: https://lore.kernel.org/u-boot/20230821135111.3558478-5-alpernebiyasak@gmail.com/
- Reviewed-by: Simon Glass <sjg@chromium.org>
- ---
- drivers/video/Kconfig | 13 ++++++++++++
- drivers/video/video-uclass.c | 40 +++++++++++++++++++++++++++++++++---
- include/video.h | 40 ++++++++++++++++++++++++++++++++++--
- 3 files changed, 88 insertions(+), 5 deletions(-)
- diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
- index 7808ae7919e0..7815b590481e 100644
- --- a/drivers/video/Kconfig
- +++ b/drivers/video/Kconfig
- @@ -92,6 +92,19 @@ config VIDEO_COPY
- To use this, your video driver must set @copy_base in
- struct video_uc_plat.
-
- +config VIDEO_DAMAGE
- + bool "Enable damage tracking of frame buffer regions"
- + help
- + On some machines (most ARM), the display frame buffer resides in
- + RAM. To make the display controller pick up screen updates, we
- + have to flush frame buffer contents from CPU caches into RAM which
- + can be a slow operation.
- +
- + This feature adds damage tracking to collect information about regions
- + that received updates. When we want to sync, we then only flush
- + regions of the frame buffer that were modified before, speeding up
- + screen refreshes significantly.
- +
- config BACKLIGHT_PWM
- bool "Generic PWM based Backlight Driver"
- depends on BACKLIGHT && DM_PWM
- diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c
- index ff1382f4a43b..75ab5f5ba9d7 100644
- --- a/drivers/video/video-uclass.c
- +++ b/drivers/video/video-uclass.c
- @@ -346,9 +346,38 @@ void video_set_default_colors(struct udevice *dev, bool invert)
- priv->colour_bg = video_index_to_colour(priv, back);
- }
-
- +/* Notify about changes in the frame buffer */
- +#ifdef CONFIG_VIDEO_DAMAGE
- +void video_damage(struct udevice *vid, int x, int y, int width, int height)
- +{
- + struct video_priv *priv = dev_get_uclass_priv(vid);
- + int xend = x + width;
- + int yend = y + height;
- +
- + if (x > priv->xsize)
- + return;
- +
- + if (y > priv->ysize)
- + return;
- +
- + if (xend > priv->xsize)
- + xend = priv->xsize;
- +
- + if (yend > priv->ysize)
- + yend = priv->ysize;
- +
- + /* Span a rectangle across all old and new damage */
- + priv->damage.xstart = min(x, priv->damage.xstart);
- + priv->damage.ystart = min(y, priv->damage.ystart);
- + priv->damage.xend = max(xend, priv->damage.xend);
- + priv->damage.yend = max(yend, priv->damage.yend);
- +}
- +#endif
- +
- /* Flush video activity to the caches */
- int video_sync(struct udevice *vid, bool force)
- {
- + struct video_priv *priv = dev_get_uclass_priv(vid);
- struct video_ops *ops = video_get_ops(vid);
- int ret;
-
- @@ -364,15 +393,12 @@ int video_sync(struct udevice *vid, bool force)
- * out whether it exists? For now, ARM is safe.
- */
- #if defined(CONFIG_ARM) && !CONFIG_IS_ENABLED(SYS_DCACHE_OFF)
- - struct video_priv *priv = dev_get_uclass_priv(vid);
- -
- if (priv->flush_dcache) {
- flush_dcache_range((ulong)priv->fb,
- ALIGN((ulong)priv->fb + priv->fb_size,
- CONFIG_SYS_CACHELINE_SIZE));
- }
- #elif defined(CONFIG_VIDEO_SANDBOX_SDL)
- - struct video_priv *priv = dev_get_uclass_priv(vid);
- static ulong last_sync;
-
- if (force || get_timer(last_sync) > 100) {
- @@ -380,6 +406,14 @@ int video_sync(struct udevice *vid, bool force)
- last_sync = get_timer(0);
- }
- #endif
- +
- + if (IS_ENABLED(CONFIG_VIDEO_DAMAGE)) {
- + priv->damage.xstart = priv->xsize;
- + priv->damage.ystart = priv->ysize;
- + priv->damage.xend = 0;
- + priv->damage.yend = 0;
- + }
- +
- return 0;
- }
-
- diff --git a/include/video.h b/include/video.h
- index 4d8df9baaada..d2dabb66e9e6 100644
- --- a/include/video.h
- +++ b/include/video.h
- @@ -88,6 +88,11 @@ enum video_format {
- * @fb_size: Frame buffer size
- * @copy_fb: Copy of the frame buffer to keep up to date; see struct
- * video_uc_plat
- + * @damage: A bounding box of framebuffer regions updated since last sync
- + * @damage.xstart: X start position in pixels from the left
- + * @damage.ystart: Y start position in pixels from the top
- + * @damage.xend: X end position in pixels from the left
- + * @damage.xend: Y end position in pixels from the top
- * @line_length: Length of each frame buffer line, in bytes. This can be
- * set by the driver, but if not, the uclass will set it after
- * probing
- @@ -115,6 +120,12 @@ struct video_priv {
- void *fb;
- int fb_size;
- void *copy_fb;
- + struct {
- + int xstart;
- + int ystart;
- + int xend;
- + int yend;
- + } damage;
- int line_length;
- u32 colour_fg;
- u32 colour_bg;
- @@ -257,8 +268,9 @@ int video_fill_part(struct udevice *dev, int xstart, int ystart, int xend,
- * @return: 0 on success, error code otherwise
- *
- * Some frame buffers are cached or have a secondary frame buffer. This
- - * function syncs these up so that the current contents of the U-Boot frame
- - * buffer are displayed to the user.
- + * function syncs the damaged parts of them up so that the current contents
- + * of the U-Boot frame buffer are displayed to the user. It clears the damage
- + * buffer.
- */
- int video_sync(struct udevice *vid, bool force);
-
- @@ -378,6 +390,30 @@ static inline int video_sync_copy_all(struct udevice *dev)
-
- #endif
-
- +#ifdef CONFIG_VIDEO_DAMAGE
- +/**
- + * video_damage() - Notify the video subsystem about screen updates.
- + *
- + * @vid: Device to sync
- + * @x: Upper left X coordinate of the damaged rectangle
- + * @y: Upper left Y coordinate of the damaged rectangle
- + * @width: Width of the damaged rectangle
- + * @height: Height of the damaged rectangle
- + *
- + * Some frame buffers are cached or have a secondary frame buffer. This
- + * function notifies the video subsystem about rectangles that were updated
- + * within the frame buffer. They may only get written to the screen on the
- + * next call to video_sync().
- + */
- +void video_damage(struct udevice *vid, int x, int y, int width, int height);
- +#else
- +static inline void video_damage(struct udevice *vid, int x, int y, int width,
- + int height)
- +{
- + return;
- +}
- +#endif /* CONFIG_VIDEO_DAMAGE */
- +
- /**
- * video_is_active() - Test if one video device it active
- *
- --
- 2.45.2
- From 5613cd630801ccb329895f62c27b8690a2cbf74c Mon Sep 17 00:00:00 2001
- From: Alexander Graf <agraf@csgraf.de>
- Date: Fri, 10 Jun 2022 00:59:16 +0200
- Subject: [PATCH 05/13] dm: video: Add damage notification on display fills
- Let's report the video damage when we fill parts of the screen. This
- way we can later lazily flush only relevant regions to hardware.
- Signed-off-by: Alexander Graf <agraf@csgraf.de>
- Reported-by: Da Xue <da@libre.computer>
- [Alper: Move from video_clear() to video_fill(), video_fill_part()]
- Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
- Reviewed-by: Simon Glass <sjg@chromium.org>
- Link: https://lore.kernel.org/u-boot/20230821135111.3558478-6-alpernebiyasak@gmail.com/
- ---
- drivers/video/video-uclass.c | 4 ++++
- 1 file changed, 4 insertions(+)
- diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c
- index 75ab5f5ba9d7..ca348101817a 100644
- --- a/drivers/video/video-uclass.c
- +++ b/drivers/video/video-uclass.c
- @@ -195,6 +195,8 @@ int video_fill_part(struct udevice *dev, int xstart, int ystart, int xend,
- if (ret)
- return ret;
-
- + video_damage(dev, xstart, ystart, xend - xstart, yend - ystart);
- +
- return 0;
- }
-
- @@ -244,6 +246,8 @@ int video_fill(struct udevice *dev, u32 colour)
- if (ret)
- return ret;
-
- + video_damage(dev, 0, 0, priv->xsize, priv->ysize);
- +
- return video_sync(dev, false);
- }
-
- --
- 2.45.2
- From 4e29f9d2190f2ea390d5321192f5e71193d62f71 Mon Sep 17 00:00:00 2001
- From: Alexander Graf <agraf@csgraf.de>
- Date: Fri, 10 Jun 2022 00:59:17 +0200
- Subject: [PATCH 06/13] vidconsole: Add damage notifications to all vidconsole
- drivers
- Now that we have a damage tracking API, let's populate damage done by
- vidconsole drivers. We try to declare as little memory as damaged as
- possible.
- Signed-off-by: Alexander Graf <agraf@csgraf.de>
- Reported-by: Da Xue <da@libre.computer>
- [Alper: Rebase for met->baseline, fontdata->height/width, make rotated
- console_putc_xy() damages pass tests, edit patch message]
- Co-developed-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
- Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
- Link: https://lore.kernel.org/u-boot/20230821135111.3558478-7-alpernebiyasak@gmail.com/
- ---
- drivers/video/console_normal.c | 18 +++++++++++
- drivers/video/console_rotate.c | 54 ++++++++++++++++++++++++++++++++
- drivers/video/console_truetype.c | 21 +++++++++++++
- 3 files changed, 93 insertions(+)
- diff --git a/drivers/video/console_normal.c b/drivers/video/console_normal.c
- index 6f4194a18147..51ac8cc78e9d 100644
- --- a/drivers/video/console_normal.c
- +++ b/drivers/video/console_normal.c
- @@ -39,6 +39,12 @@ static int console_set_row(struct udevice *dev, uint row, int clr)
- if (ret)
- return ret;
-
- + video_damage(dev->parent,
- + 0,
- + fontdata->height * row,
- + vid_priv->xsize,
- + fontdata->height);
- +
- return 0;
- }
-
- @@ -60,6 +66,12 @@ static int console_move_rows(struct udevice *dev, uint rowdst,
- if (ret)
- return ret;
-
- + video_damage(dev->parent,
- + 0,
- + fontdata->height * rowdst,
- + vid_priv->xsize,
- + fontdata->height * count);
- +
- return 0;
- }
-
- @@ -91,6 +103,12 @@ static int console_putc_xy(struct udevice *dev, uint x_frac, uint y, int cp)
- if (ret)
- return ret;
-
- + video_damage(dev->parent,
- + x,
- + y,
- + fontdata->width,
- + fontdata->height);
- +
- ret = vidconsole_sync_copy(dev, start, line);
- if (ret)
- return ret;
- diff --git a/drivers/video/console_rotate.c b/drivers/video/console_rotate.c
- index dc9698362741..5c4a98f6cad0 100644
- --- a/drivers/video/console_rotate.c
- +++ b/drivers/video/console_rotate.c
- @@ -36,6 +36,12 @@ static int console_set_row_1(struct udevice *dev, uint row, int clr)
- if (ret)
- return ret;
-
- + video_damage(dev->parent,
- + vid_priv->xsize - ((row + 1) * fontdata->height),
- + 0,
- + fontdata->height,
- + vid_priv->ysize);
- +
- return 0;
- }
-
- @@ -64,6 +70,12 @@ static int console_move_rows_1(struct udevice *dev, uint rowdst, uint rowsrc,
- dst += vid_priv->line_length;
- }
-
- + video_damage(dev->parent,
- + vid_priv->xsize - ((rowdst + count) * fontdata->height),
- + 0,
- + count * fontdata->height,
- + vid_priv->ysize);
- +
- return 0;
- }
-
- @@ -97,6 +109,12 @@ static int console_putc_xy_1(struct udevice *dev, uint x_frac, uint y, int cp)
- if (ret)
- return ret;
-
- + video_damage(dev->parent,
- + vid_priv->xsize - y - fontdata->height,
- + linenum - 1,
- + fontdata->height,
- + fontdata->width);
- +
- return VID_TO_POS(fontdata->width);
- }
-
- @@ -122,6 +140,12 @@ static int console_set_row_2(struct udevice *dev, uint row, int clr)
- if (ret)
- return ret;
-
- + video_damage(dev->parent,
- + 0,
- + vid_priv->ysize - (row + 1) * fontdata->height,
- + vid_priv->xsize,
- + fontdata->height);
- +
- return 0;
- }
-
- @@ -143,6 +167,12 @@ static int console_move_rows_2(struct udevice *dev, uint rowdst, uint rowsrc,
- vidconsole_memmove(dev, dst, src,
- fontdata->height * vid_priv->line_length * count);
-
- + video_damage(dev->parent,
- + 0,
- + vid_priv->ysize - (rowdst + count) * fontdata->height,
- + vid_priv->xsize,
- + count * fontdata->height);
- +
- return 0;
- }
-
- @@ -176,6 +206,12 @@ static int console_putc_xy_2(struct udevice *dev, uint x_frac, uint y, int cp)
- if (ret)
- return ret;
-
- + video_damage(dev->parent,
- + x - fontdata->width + 1,
- + linenum - fontdata->height + 1,
- + fontdata->width,
- + fontdata->height);
- +
- return VID_TO_POS(fontdata->width);
- }
-
- @@ -200,6 +236,12 @@ static int console_set_row_3(struct udevice *dev, uint row, int clr)
- if (ret)
- return ret;
-
- + video_damage(dev->parent,
- + row * fontdata->height,
- + 0,
- + fontdata->height,
- + vid_priv->ysize);
- +
- return 0;
- }
-
- @@ -226,6 +268,12 @@ static int console_move_rows_3(struct udevice *dev, uint rowdst, uint rowsrc,
- dst += vid_priv->line_length;
- }
-
- + video_damage(dev->parent,
- + rowdst * fontdata->height,
- + 0,
- + count * fontdata->height,
- + vid_priv->ysize);
- +
- return 0;
- }
-
- @@ -258,6 +306,12 @@ static int console_putc_xy_3(struct udevice *dev, uint x_frac, uint y, int cp)
- if (ret)
- return ret;
-
- + video_damage(dev->parent,
- + y,
- + linenum - fontdata->width + 1,
- + fontdata->height,
- + fontdata->width);
- +
- return VID_TO_POS(fontdata->width);
- }
-
- diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c
- index c435162d3f94..6a17f732fc26 100644
- --- a/drivers/video/console_truetype.c
- +++ b/drivers/video/console_truetype.c
- @@ -190,6 +190,7 @@ struct console_tt_store {
- static int console_truetype_set_row(struct udevice *dev, uint row, int clr)
- {
- struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent);
- + struct vidconsole_priv *vc_priv = dev_get_uclass_priv(dev);
- struct console_tt_priv *priv = dev_get_priv(dev);
- struct console_tt_metrics *met = priv->cur_met;
- void *end, *line;
- @@ -233,6 +234,12 @@ static int console_truetype_set_row(struct udevice *dev, uint row, int clr)
- if (ret)
- return ret;
-
- + video_damage(dev->parent,
- + 0,
- + vc_priv->y_charsize * row,
- + vid_priv->xsize,
- + vc_priv->y_charsize);
- +
- return 0;
- }
-
- @@ -240,6 +247,7 @@ static int console_truetype_move_rows(struct udevice *dev, uint rowdst,
- uint rowsrc, uint count)
- {
- struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent);
- + struct vidconsole_priv *vc_priv = dev_get_uclass_priv(dev);
- struct console_tt_priv *priv = dev_get_priv(dev);
- struct console_tt_metrics *met = priv->cur_met;
- void *dst;
- @@ -258,6 +266,12 @@ static int console_truetype_move_rows(struct udevice *dev, uint rowdst,
- for (i = 0; i < priv->pos_ptr; i++)
- priv->pos[i].ypos -= diff;
-
- + video_damage(dev->parent,
- + 0,
- + vc_priv->y_charsize * rowdst,
- + vid_priv->xsize,
- + vc_priv->y_charsize * count);
- +
- return 0;
- }
-
- @@ -418,6 +432,13 @@ static int console_truetype_putc_xy(struct udevice *dev, uint x, uint y,
-
- line += vid_priv->line_length;
- }
- +
- + video_damage(dev->parent,
- + VID_TO_PIXEL(x) + xoff,
- + y + met->baseline + yoff,
- + width,
- + height);
- +
- ret = vidconsole_sync_copy(dev, start, line);
- if (ret)
- return ret;
- --
- 2.45.2
- From 11fa5d7c68878f629c8fff7dc28a76acaf1252ab Mon Sep 17 00:00:00 2001
- From: Alper Nebi Yasak <alpernebiyasak@gmail.com>
- Date: Fri, 18 Aug 2023 17:55:08 +0300
- Subject: [PATCH 07/13] video: test: Test video damage tracking via vidconsole
- With VIDEO_DAMAGE, the video uclass tracks updated regions of the frame
- buffer in order to avoid unnecessary work during a video sync. Enable
- the config in sandbox and add a test for it, by printing strings at a
- few locations and checking the tracked region.
- Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
- Reviewed-by: Simon Glass <sjg@chromium.org>
- Link: https://lore.kernel.org/u-boot/20230821135111.3558478-8-alpernebiyasak@gmail.com/
- ---
- configs/sandbox_defconfig | 1 +
- test/dm/video.c | 56 +++++++++++++++++++++++++++++++++++++++
- 2 files changed, 57 insertions(+)
- diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
- index da8c1976d7bd..6bc20ec34169 100644
- --- a/configs/sandbox_defconfig
- +++ b/configs/sandbox_defconfig
- @@ -319,6 +319,7 @@ CONFIG_USB_ETH_CDC=y
- CONFIG_VIDEO=y
- CONFIG_VIDEO_FONT_SUN12X22=y
- CONFIG_VIDEO_COPY=y
- +CONFIG_VIDEO_DAMAGE=y
- CONFIG_CONSOLE_ROTATION=y
- CONFIG_CONSOLE_TRUETYPE=y
- CONFIG_CONSOLE_TRUETYPE_CANTORAONE=y
- diff --git a/test/dm/video.c b/test/dm/video.c
- index 4798f2205a99..119c43153165 100644
- --- a/test/dm/video.c
- +++ b/test/dm/video.c
- @@ -710,3 +710,59 @@ static int dm_test_video_copy(struct unit_test_state *uts)
- return 0;
- }
- DM_TEST(dm_test_video_copy, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
- +
- +/* Test video damage tracking */
- +static int dm_test_video_damage(struct unit_test_state *uts)
- +{
- + struct sandbox_sdl_plat *plat;
- + struct udevice *dev, *con;
- + struct video_priv *priv;
- + const char *test_string_1 = "Criticism may not be agreeable, ";
- + const char *test_string_2 = "but it is necessary.";
- + const char *test_string_3 = "It fulfils the same function as pain in the human body.";
- +
- + if (!IS_ENABLED(CONFIG_VIDEO_DAMAGE))
- + return -EAGAIN;
- +
- + ut_assertok(uclass_find_device(UCLASS_VIDEO, 0, &dev));
- + ut_assert(!device_active(dev));
- + plat = dev_get_plat(dev);
- + plat->font_size = 32;
- +
- + ut_assertok(video_get_nologo(uts, &dev));
- + ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
- + priv = dev_get_uclass_priv(dev);
- +
- + vidconsole_position_cursor(con, 14, 10);
- + vidconsole_put_string(con, test_string_2);
- + ut_asserteq(449, priv->damage.xstart);
- + ut_asserteq(325, priv->damage.ystart);
- + ut_asserteq(661, priv->damage.xend);
- + ut_asserteq(350, priv->damage.yend);
- +
- + vidconsole_position_cursor(con, 7, 5);
- + vidconsole_put_string(con, test_string_1);
- + ut_asserteq(225, priv->damage.xstart);
- + ut_asserteq(164, priv->damage.ystart);
- + ut_asserteq(661, priv->damage.xend);
- + ut_asserteq(350, priv->damage.yend);
- +
- + vidconsole_position_cursor(con, 21, 15);
- + vidconsole_put_string(con, test_string_3);
- + ut_asserteq(225, priv->damage.xstart);
- + ut_asserteq(164, priv->damage.ystart);
- + ut_asserteq(1280, priv->damage.xend);
- + ut_asserteq(510, priv->damage.yend);
- +
- + video_sync(dev, false);
- + ut_asserteq(priv->xsize, priv->damage.xstart);
- + ut_asserteq(priv->ysize, priv->damage.ystart);
- + ut_asserteq(0, priv->damage.xend);
- + ut_asserteq(0, priv->damage.yend);
- +
- + ut_asserteq(7339, compress_frame_buffer(uts, dev, false));
- + ut_assertok(check_copy_frame_buffer(uts, dev));
- +
- + return 0;
- +}
- +DM_TEST(dm_test_video_damage, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
- --
- 2.45.2
- From 80a32fe8f34466e6b86553018f47192a1fef3c6a Mon Sep 17 00:00:00 2001
- From: Alexander Graf <agraf@csgraf.de>
- Date: Fri, 10 Jun 2022 00:59:18 +0200
- Subject: [PATCH 08/13] video: Add damage notification on bmp display
- Let's report the video damage when we draw a bitmap on the screen. This
- way we can later lazily flush only relevant regions to hardware.
- Signed-off-by: Alexander Graf <agraf@csgraf.de>
- Reported-by: Da Xue <da@libre.computer>
- Reviewed-by: Simon Glass <sjg@chromium.org>
- Link: https://lore.kernel.org/u-boot/20230821135111.3558478-9-alpernebiyasak@gmail.com/
- ---
- drivers/video/video_bmp.c | 2 ++
- 1 file changed, 2 insertions(+)
- diff --git a/drivers/video/video_bmp.c b/drivers/video/video_bmp.c
- index ad512d99a1b9..78de95607924 100644
- --- a/drivers/video/video_bmp.c
- +++ b/drivers/video/video_bmp.c
- @@ -459,6 +459,8 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y,
- break;
- };
-
- + video_damage(dev, x, y, width, height);
- +
- /* Find the position of the top left of the image in the framebuffer */
- fb = (uchar *)(priv->fb + y * priv->line_length + x * bpix / 8);
- ret = video_sync_copy(dev, start, fb);
- --
- 2.45.2
- From 7afe761e51bfb0f24fd4547e8bec1826aaf2e6a0 Mon Sep 17 00:00:00 2001
- From: Alexander Graf <agraf@csgraf.de>
- Date: Fri, 10 Jun 2022 00:59:19 +0200
- Subject: [PATCH 09/13] efi_loader: GOP: Add damage notification on BLT
- Now that we have a damage tracking API, let's populate damage done by
- UEFI payloads when they BLT data onto the screen.
- Signed-off-by: Alexander Graf <agraf@csgraf.de>
- Reported-by: Da Xue <da@libre.computer>
- Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
- [Alper: Add struct comment for new member]
- Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
- Reviewed-by: Simon Glass <sjg@chromium.org>
- Link: https://lore.kernel.org/u-boot/20230821135111.3558478-10-alpernebiyasak@gmail.com/
- ---
- lib/efi_loader/efi_gop.c | 7 +++++++
- 1 file changed, 7 insertions(+)
- diff --git a/lib/efi_loader/efi_gop.c b/lib/efi_loader/efi_gop.c
- index 41e12fa72460..1694e23dcc62 100644
- --- a/lib/efi_loader/efi_gop.c
- +++ b/lib/efi_loader/efi_gop.c
- @@ -24,6 +24,7 @@ static const efi_guid_t efi_gop_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
- * @ops: graphical output protocol interface
- * @info: graphical output mode information
- * @mode: graphical output mode
- + * @vdev: backing video device
- * @bpix: bits per pixel
- * @fb: frame buffer
- */
- @@ -32,6 +33,7 @@ struct efi_gop_obj {
- struct efi_gop ops;
- struct efi_gop_mode_info info;
- struct efi_gop_mode mode;
- + struct udevice *vdev;
- /* Fields we only have access to during init */
- u32 bpix;
- void *fb;
- @@ -120,6 +122,7 @@ static __always_inline efi_status_t gop_blt_int(struct efi_gop *this,
- u32 *fb32 = gopobj->fb;
- u16 *fb16 = gopobj->fb;
- struct efi_gop_pixel *buffer = __builtin_assume_aligned(bufferp, 4);
- + bool blt_to_video = (operation != EFI_BLT_VIDEO_TO_BLT_BUFFER);
-
- if (delta) {
- /* Check for 4 byte alignment */
- @@ -243,6 +246,9 @@ static __always_inline efi_status_t gop_blt_int(struct efi_gop *this,
- dlineoff += dwidth;
- }
-
- + if (blt_to_video)
- + video_damage(gopobj->vdev, dx, dy, width, height);
- +
- return EFI_SUCCESS;
- }
-
- @@ -549,6 +555,7 @@ efi_status_t efi_gop_register(void)
- gopobj->info.pixels_per_scanline = col;
- gopobj->bpix = bpix;
- gopobj->fb = map_sysmem(fb_base, fb_size);
- + gopobj->vdev = vdev;
-
- return EFI_SUCCESS;
- }
- --
- 2.45.2
- From 134415d6cbe38f7ab630f978a602b6e15929feea Mon Sep 17 00:00:00 2001
- From: Alexander Graf <agraf@csgraf.de>
- Date: Fri, 10 Jun 2022 00:59:20 +0200
- Subject: [PATCH 10/13] video: Only dcache flush damaged lines
- Now that we have a damage area tells us which parts of the frame buffer
- actually need updating, let's only dcache flush those on video_sync()
- calls. With this optimization in place, frame buffer updates - especially
- on large screen such as 4k displays - speed up significantly.
- Signed-off-by: Alexander Graf <agraf@csgraf.de>
- Reported-by: Da Xue <da@libre.computer>
- [Alper: Use damage.xstart/yend, IS_ENABLED()]
- Co-developed-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
- Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
- Link: https://lore.kernel.org/u-boot/20230821135111.3558478-11-alpernebiyasak@gmail.com/
- ---
- drivers/video/video-uclass.c | 43 +++++++++++++++++++++++++++++++-----
- 1 file changed, 38 insertions(+), 5 deletions(-)
- diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c
- index ca348101817a..add7a85b20fe 100644
- --- a/drivers/video/video-uclass.c
- +++ b/drivers/video/video-uclass.c
- @@ -378,6 +378,40 @@ void video_damage(struct udevice *vid, int x, int y, int width, int height)
- }
- #endif
-
- +#if defined(CONFIG_ARM) && !CONFIG_IS_ENABLED(SYS_DCACHE_OFF)
- +static void video_flush_dcache(struct udevice *vid, bool use_copy)
- +{
- + struct video_priv *priv = dev_get_uclass_priv(vid);
- + ulong fb = use_copy ? (ulong)priv->copy_fb : (ulong)priv->fb;
- +
- + if (!priv->flush_dcache)
- + return;
- +
- + if (!IS_ENABLED(CONFIG_VIDEO_DAMAGE)) {
- + flush_dcache_range(fb, ALIGN(fb + priv->fb_size,
- + CONFIG_SYS_CACHELINE_SIZE));
- +
- + return;
- + }
- +
- + if (priv->damage.xend && priv->damage.yend) {
- + int lstart = priv->damage.xstart * VNBYTES(priv->bpix);
- + int lend = priv->damage.xend * VNBYTES(priv->bpix);
- + int y;
- +
- + for (y = priv->damage.ystart; y < priv->damage.yend; y++) {
- + ulong start = fb + (y * priv->line_length) + lstart;
- + ulong end = start + lend - lstart;
- +
- + start = ALIGN_DOWN(start, CONFIG_SYS_CACHELINE_SIZE);
- + end = ALIGN(end, CONFIG_SYS_CACHELINE_SIZE);
- +
- + flush_dcache_range(start, end);
- + }
- + }
- +}
- +#endif
- +
- /* Flush video activity to the caches */
- int video_sync(struct udevice *vid, bool force)
- {
- @@ -397,11 +431,10 @@ int video_sync(struct udevice *vid, bool force)
- * out whether it exists? For now, ARM is safe.
- */
- #if defined(CONFIG_ARM) && !CONFIG_IS_ENABLED(SYS_DCACHE_OFF)
- - if (priv->flush_dcache) {
- - flush_dcache_range((ulong)priv->fb,
- - ALIGN((ulong)priv->fb + priv->fb_size,
- - CONFIG_SYS_CACHELINE_SIZE));
- - }
- + video_flush_dcache(vid, false);
- +
- + if (IS_ENABLED(CONFIG_VIDEO_COPY))
- + video_flush_dcache(vid, true);
- #elif defined(CONFIG_VIDEO_SANDBOX_SDL)
- static ulong last_sync;
-
- --
- 2.45.2
- From d3f1653a87d51c5ecf187b19ecb60a2f740fb8e2 Mon Sep 17 00:00:00 2001
- From: Alexander Graf <agraf@csgraf.de>
- Date: Fri, 10 Jun 2022 00:59:21 +0200
- Subject: [PATCH 11/13] video: Use VIDEO_DAMAGE for VIDEO_COPY
- CONFIG_VIDEO_COPY implemented a range-based copying mechanism: If we
- print a single character, it will always copy the full range of bytes
- from the top left corner of the character to the lower right onto the
- uncached frame buffer. This includes pretty much the full line contents
- of the printed character.
- Since we now have proper damage tracking, let's make use of that to reduce
- the amount of data we need to copy. With this patch applied, we will only
- copy the tiny rectangle surrounding characters when we print them,
- speeding up the video console.
- After this, changes to the main frame buffer are not immediately copied
- to the copy frame buffer, but postponed until the next video device
- sync. So issue an explicit sync before inspecting the copy frame buffer
- contents for the video tests.
- Signed-off-by: Alexander Graf <agraf@csgraf.de>
- [Alper: Rebase for fontdata->height/w, fill_part(), fix memmove(dev),
- drop from defconfig, use damage.xstart/yend, use IS_ENABLED(),
- call video_sync() before copy_fb check, update video_copy test]
- Co-developed-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
- Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
- Link: https://lore.kernel.org/u-boot/20230821135111.3558478-12-alpernebiyasak@gmail.com/
- ---
- configs/sandbox_defconfig | 1 -
- drivers/video/Kconfig | 5 ++
- drivers/video/console_normal.c | 13 +----
- drivers/video/console_rotate.c | 44 +++-----------
- drivers/video/console_truetype.c | 16 +-----
- drivers/video/vidconsole-uclass.c | 16 ------
- drivers/video/video-uclass.c | 96 ++++++++-----------------------
- drivers/video/video_bmp.c | 7 ---
- include/video.h | 37 ------------
- include/video_console.h | 52 -----------------
- test/dm/video.c | 3 +-
- 11 files changed, 43 insertions(+), 247 deletions(-)
- diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
- index 6bc20ec34169..da8c1976d7bd 100644
- --- a/configs/sandbox_defconfig
- +++ b/configs/sandbox_defconfig
- @@ -319,7 +319,6 @@ CONFIG_USB_ETH_CDC=y
- CONFIG_VIDEO=y
- CONFIG_VIDEO_FONT_SUN12X22=y
- CONFIG_VIDEO_COPY=y
- -CONFIG_VIDEO_DAMAGE=y
- CONFIG_CONSOLE_ROTATION=y
- CONFIG_CONSOLE_TRUETYPE=y
- CONFIG_CONSOLE_TRUETYPE_CANTORAONE=y
- diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
- index 7815b590481e..88c6f8e68976 100644
- --- a/drivers/video/Kconfig
- +++ b/drivers/video/Kconfig
- @@ -83,11 +83,14 @@ config VIDEO_PCI_DEFAULT_FB_SIZE
-
- config VIDEO_COPY
- bool "Enable copying the frame buffer to a hardware copy"
- + select VIDEO_DAMAGE
- help
- On some machines (e.g. x86), reading from the frame buffer is very
- slow because it is uncached. To improve performance, this feature
- allows the frame buffer to be kept in cached memory (allocated by
- U-Boot) and then copied to the hardware frame-buffer as needed.
- + It uses the VIDEO_DAMAGE feature to keep track of regions to copy
- + and will only copy actually touched regions.
-
- To use this, your video driver must set @copy_base in
- struct video_uc_plat.
- @@ -105,6 +108,8 @@ config VIDEO_DAMAGE
- regions of the frame buffer that were modified before, speeding up
- screen refreshes significantly.
-
- + It is also used by VIDEO_COPY to identify which regions changed.
- +
- config BACKLIGHT_PWM
- bool "Generic PWM based Backlight Driver"
- depends on BACKLIGHT && DM_PWM
- diff --git a/drivers/video/console_normal.c b/drivers/video/console_normal.c
- index 51ac8cc78e9d..07db613ac53c 100644
- --- a/drivers/video/console_normal.c
- +++ b/drivers/video/console_normal.c
- @@ -35,10 +35,6 @@ static int console_set_row(struct udevice *dev, uint row, int clr)
- fill_pixel_and_goto_next(&dst, clr, pbytes, pbytes);
- end = dst;
-
- - ret = vidconsole_sync_copy(dev, line, end);
- - if (ret)
- - return ret;
- -
- video_damage(dev->parent,
- 0,
- fontdata->height * row,
- @@ -57,14 +53,11 @@ static int console_move_rows(struct udevice *dev, uint rowdst,
- void *dst;
- void *src;
- int size;
- - int ret;
-
- dst = vid_priv->fb + rowdst * fontdata->height * vid_priv->line_length;
- src = vid_priv->fb + rowsrc * fontdata->height * vid_priv->line_length;
- size = fontdata->height * vid_priv->line_length * count;
- - ret = vidconsole_memmove(dev, dst, src, size);
- - if (ret)
- - return ret;
- + memmove(dst, src, size);
-
- video_damage(dev->parent,
- 0,
- @@ -109,10 +102,6 @@ static int console_putc_xy(struct udevice *dev, uint x_frac, uint y, int cp)
- fontdata->width,
- fontdata->height);
-
- - ret = vidconsole_sync_copy(dev, start, line);
- - if (ret)
- - return ret;
- -
- return VID_TO_POS(fontdata->width);
- }
-
- diff --git a/drivers/video/console_rotate.c b/drivers/video/console_rotate.c
- index 5c4a98f6cad0..9f8e1b92770c 100644
- --- a/drivers/video/console_rotate.c
- +++ b/drivers/video/console_rotate.c
- @@ -21,7 +21,6 @@ static int console_set_row_1(struct udevice *dev, uint row, int clr)
- int pbytes = VNBYTES(vid_priv->bpix);
- void *start, *dst, *line;
- int i, j;
- - int ret;
-
- start = vid_priv->fb + vid_priv->line_length -
- (row + 1) * fontdata->height * pbytes;
- @@ -32,9 +31,6 @@ static int console_set_row_1(struct udevice *dev, uint row, int clr)
- fill_pixel_and_goto_next(&dst, clr, pbytes, pbytes);
- line += vid_priv->line_length;
- }
- - ret = vidconsole_sync_copy(dev, start, line);
- - if (ret)
- - return ret;
-
- video_damage(dev->parent,
- vid_priv->xsize - ((row + 1) * fontdata->height),
- @@ -54,7 +50,7 @@ static int console_move_rows_1(struct udevice *dev, uint rowdst, uint rowsrc,
- int pbytes = VNBYTES(vid_priv->bpix);
- void *dst;
- void *src;
- - int j, ret;
- + int j;
-
- dst = vid_priv->fb + vid_priv->line_length -
- (rowdst + count) * fontdata->height * pbytes;
- @@ -62,10 +58,7 @@ static int console_move_rows_1(struct udevice *dev, uint rowdst, uint rowsrc,
- (rowsrc + count) * fontdata->height * pbytes;
-
- for (j = 0; j < vid_priv->ysize; j++) {
- - ret = vidconsole_memmove(dev, dst, src,
- - fontdata->height * pbytes * count);
- - if (ret)
- - return ret;
- + memmove(dst, src, fontdata->height * pbytes * count);
- src += vid_priv->line_length;
- dst += vid_priv->line_length;
- }
- @@ -105,10 +98,6 @@ static int console_putc_xy_1(struct udevice *dev, uint x_frac, uint y, int cp)
- return ret;
-
- /* We draw backwards from 'start, so account for the first line */
- - ret = vidconsole_sync_copy(dev, start - vid_priv->line_length, line);
- - if (ret)
- - return ret;
- -
- video_damage(dev->parent,
- vid_priv->xsize - y - fontdata->height,
- linenum - 1,
- @@ -126,7 +115,7 @@ static int console_set_row_2(struct udevice *dev, uint row, int clr)
- struct video_fontdata *fontdata = priv->fontdata;
- void *start, *line, *dst, *end;
- int pixels = fontdata->height * vid_priv->xsize;
- - int i, ret;
- + int i;
- int pbytes = VNBYTES(vid_priv->bpix);
-
- start = vid_priv->fb + vid_priv->ysize * vid_priv->line_length -
- @@ -136,9 +125,6 @@ static int console_set_row_2(struct udevice *dev, uint row, int clr)
- for (i = 0; i < pixels; i++)
- fill_pixel_and_goto_next(&dst, clr, pbytes, pbytes);
- end = dst;
- - ret = vidconsole_sync_copy(dev, start, end);
- - if (ret)
- - return ret;
-
- video_damage(dev->parent,
- 0,
- @@ -164,8 +150,7 @@ static int console_move_rows_2(struct udevice *dev, uint rowdst, uint rowsrc,
- vid_priv->line_length;
- src = end - (rowsrc + count) * fontdata->height *
- vid_priv->line_length;
- - vidconsole_memmove(dev, dst, src,
- - fontdata->height * vid_priv->line_length * count);
- + memmove(dst, src, fontdata->height * vid_priv->line_length * count);
-
- video_damage(dev->parent,
- 0,
- @@ -201,11 +186,6 @@ static int console_putc_xy_2(struct udevice *dev, uint x_frac, uint y, int cp)
- if (ret)
- return ret;
-
- - /* Add 4 bytes to allow for the first pixel writen */
- - ret = vidconsole_sync_copy(dev, start + 4, line);
- - if (ret)
- - return ret;
- -
- video_damage(dev->parent,
- x - fontdata->width + 1,
- linenum - fontdata->height + 1,
- @@ -222,7 +202,7 @@ static int console_set_row_3(struct udevice *dev, uint row, int clr)
- struct video_fontdata *fontdata = priv->fontdata;
- int pbytes = VNBYTES(vid_priv->bpix);
- void *start, *dst, *line;
- - int i, j, ret;
- + int i, j;
-
- start = vid_priv->fb + row * fontdata->height * pbytes;
- line = start;
- @@ -232,9 +212,6 @@ static int console_set_row_3(struct udevice *dev, uint row, int clr)
- fill_pixel_and_goto_next(&dst, clr, pbytes, pbytes);
- line += vid_priv->line_length;
- }
- - ret = vidconsole_sync_copy(dev, start, line);
- - if (ret)
- - return ret;
-
- video_damage(dev->parent,
- row * fontdata->height,
- @@ -254,16 +231,13 @@ static int console_move_rows_3(struct udevice *dev, uint rowdst, uint rowsrc,
- int pbytes = VNBYTES(vid_priv->bpix);
- void *dst;
- void *src;
- - int j, ret;
- + int j;
-
- dst = vid_priv->fb + rowdst * fontdata->height * pbytes;
- src = vid_priv->fb + rowsrc * fontdata->height * pbytes;
-
- for (j = 0; j < vid_priv->ysize; j++) {
- - ret = vidconsole_memmove(dev, dst, src,
- - fontdata->height * pbytes * count);
- - if (ret)
- - return ret;
- + memmove(dst, src, fontdata->height * pbytes * count);
- src += vid_priv->line_length;
- dst += vid_priv->line_length;
- }
- @@ -299,10 +273,6 @@ static int console_putc_xy_3(struct udevice *dev, uint x_frac, uint y, int cp)
- line = start;
-
- ret = fill_char_horizontally(pfont, &line, vid_priv, fontdata, NORMAL_DIRECTION);
- - if (ret)
- - return ret;
- - /* Add a line to allow for the first pixels writen */
- - ret = vidconsole_sync_copy(dev, start + vid_priv->line_length, line);
- if (ret)
- return ret;
-
- diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c
- index 6a17f732fc26..58dcd8e050c3 100644
- --- a/drivers/video/console_truetype.c
- +++ b/drivers/video/console_truetype.c
- @@ -194,7 +194,6 @@ static int console_truetype_set_row(struct udevice *dev, uint row, int clr)
- struct console_tt_priv *priv = dev_get_priv(dev);
- struct console_tt_metrics *met = priv->cur_met;
- void *end, *line;
- - int ret;
-
- line = vid_priv->fb + row * met->font_size * vid_priv->line_length;
- end = line + met->font_size * vid_priv->line_length;
- @@ -230,9 +229,6 @@ static int console_truetype_set_row(struct udevice *dev, uint row, int clr)
- default:
- return -ENOSYS;
- }
- - ret = vidconsole_sync_copy(dev, line, end);
- - if (ret)
- - return ret;
-
- video_damage(dev->parent,
- 0,
- @@ -252,14 +248,11 @@ static int console_truetype_move_rows(struct udevice *dev, uint rowdst,
- struct console_tt_metrics *met = priv->cur_met;
- void *dst;
- void *src;
- - int i, diff, ret;
- + int i, diff;
-
- dst = vid_priv->fb + rowdst * met->font_size * vid_priv->line_length;
- src = vid_priv->fb + rowsrc * met->font_size * vid_priv->line_length;
- - ret = vidconsole_memmove(dev, dst, src, met->font_size *
- - vid_priv->line_length * count);
- - if (ret)
- - return ret;
- + memmove(dst, src, met->font_size * vid_priv->line_length * count);
-
- /* Scroll up our position history */
- diff = (rowsrc - rowdst) * met->font_size;
- @@ -292,7 +285,7 @@ static int console_truetype_putc_xy(struct udevice *dev, uint x, uint y,
- u8 *bits, *data;
- int advance;
- void *start, *end, *line;
- - int row, ret;
- + int row;
-
- /* First get some basic metrics about this character */
- stbtt_GetCodepointHMetrics(font, cp, &advance, &lsb);
- @@ -439,9 +432,6 @@ static int console_truetype_putc_xy(struct udevice *dev, uint x, uint y,
- width,
- height);
-
- - ret = vidconsole_sync_copy(dev, start, line);
- - if (ret)
- - return ret;
- free(data);
-
- return width_frac;
- diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c
- index 80e7adf6a1a4..6dc5162804aa 100644
- --- a/drivers/video/vidconsole-uclass.c
- +++ b/drivers/video/vidconsole-uclass.c
- @@ -759,22 +759,6 @@ UCLASS_DRIVER(vidconsole) = {
- .per_device_auto = sizeof(struct vidconsole_priv),
- };
-
- -#ifdef CONFIG_VIDEO_COPY
- -int vidconsole_sync_copy(struct udevice *dev, void *from, void *to)
- -{
- - struct udevice *vid = dev_get_parent(dev);
- -
- - return video_sync_copy(vid, from, to);
- -}
- -
- -int vidconsole_memmove(struct udevice *dev, void *dst, const void *src,
- - int size)
- -{
- - memmove(dst, src, size);
- - return vidconsole_sync_copy(dev, dst, dst + size);
- -}
- -#endif
- -
- int vidconsole_clear_and_reset(struct udevice *dev)
- {
- int ret;
- diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c
- index add7a85b20fe..3b9b9fad0975 100644
- --- a/drivers/video/video-uclass.c
- +++ b/drivers/video/video-uclass.c
- @@ -152,7 +152,7 @@ int video_fill_part(struct udevice *dev, int xstart, int ystart, int xend,
- struct video_priv *priv = dev_get_uclass_priv(dev);
- void *start, *line;
- int pixels = xend - xstart;
- - int row, i, ret;
- + int row, i;
-
- start = priv->fb + ystart * priv->line_length;
- start += xstart * VNBYTES(priv->bpix);
- @@ -191,9 +191,6 @@ int video_fill_part(struct udevice *dev, int xstart, int ystart, int xend,
- }
- line += priv->line_length;
- }
- - ret = video_sync_copy(dev, start, line);
- - if (ret)
- - return ret;
-
- video_damage(dev, xstart, ystart, xend - xstart, yend - ystart);
-
- @@ -217,7 +214,6 @@ int video_reserve_from_bloblist(struct video_handoff *ho)
- int video_fill(struct udevice *dev, u32 colour)
- {
- struct video_priv *priv = dev_get_uclass_priv(dev);
- - int ret;
-
- switch (priv->bpix) {
- case VIDEO_BPP16:
- @@ -242,9 +238,6 @@ int video_fill(struct udevice *dev, u32 colour)
- memset(priv->fb, colour, priv->fb_size);
- break;
- }
- - ret = video_sync_copy(dev, priv->fb, priv->fb + priv->fb_size);
- - if (ret)
- - return ret;
-
- video_damage(dev, 0, 0, priv->xsize, priv->ysize);
-
- @@ -412,6 +405,27 @@ static void video_flush_dcache(struct udevice *vid, bool use_copy)
- }
- #endif
-
- +static void video_flush_copy(struct udevice *vid)
- +{
- + struct video_priv *priv = dev_get_uclass_priv(vid);
- +
- + if (!priv->copy_fb)
- + return;
- +
- + if (priv->damage.xend && priv->damage.yend) {
- + int lstart = priv->damage.xstart * VNBYTES(priv->bpix);
- + int lend = priv->damage.xend * VNBYTES(priv->bpix);
- + int y;
- +
- + for (y = priv->damage.ystart; y < priv->damage.yend; y++) {
- + ulong offset = (y * priv->line_length) + lstart;
- + ulong len = lend - lstart;
- +
- + memcpy(priv->copy_fb + offset, priv->fb + offset, len);
- + }
- + }
- +}
- +
- /* Flush video activity to the caches */
- int video_sync(struct udevice *vid, bool force)
- {
- @@ -419,6 +433,9 @@ int video_sync(struct udevice *vid, bool force)
- struct video_ops *ops = video_get_ops(vid);
- int ret;
-
- + if (IS_ENABLED(CONFIG_VIDEO_COPY))
- + video_flush_copy(vid);
- +
- if (ops && ops->video_sync) {
- ret = ops->video_sync(vid);
- if (ret)
- @@ -502,69 +519,6 @@ int video_get_ysize(struct udevice *dev)
- return priv->ysize;
- }
-
- -#ifdef CONFIG_VIDEO_COPY
- -int video_sync_copy(struct udevice *dev, void *from, void *to)
- -{
- - struct video_priv *priv = dev_get_uclass_priv(dev);
- -
- - if (priv->copy_fb) {
- - long offset, size;
- -
- - /* Find the offset of the first byte to copy */
- - if ((ulong)to > (ulong)from) {
- - size = to - from;
- - offset = from - priv->fb;
- - } else {
- - size = from - to;
- - offset = to - priv->fb;
- - }
- -
- - /*
- - * Allow a bit of leeway for valid requests somewhere near the
- - * frame buffer
- - */
- - if (offset < -priv->fb_size || offset > 2 * priv->fb_size) {
- -#ifdef DEBUG
- - char str[120];
- -
- - snprintf(str, sizeof(str),
- - "[** FAULT sync_copy fb=%p, from=%p, to=%p, offset=%lx]",
- - priv->fb, from, to, offset);
- - console_puts_select_stderr(true, str);
- -#endif
- - return -EFAULT;
- - }
- -
- - /*
- - * Silently crop the memcpy. This allows callers to avoid doing
- - * this themselves. It is common for the end pointer to go a
- - * few lines after the end of the frame buffer, since most of
- - * the update algorithms terminate a line after their last write
- - */
- - if (offset + size > priv->fb_size) {
- - size = priv->fb_size - offset;
- - } else if (offset < 0) {
- - size += offset;
- - offset = 0;
- - }
- -
- - memcpy(priv->copy_fb + offset, priv->fb + offset, size);
- - }
- -
- - return 0;
- -}
- -
- -int video_sync_copy_all(struct udevice *dev)
- -{
- - struct video_priv *priv = dev_get_uclass_priv(dev);
- -
- - video_sync_copy(dev, priv->fb, priv->fb + priv->fb_size);
- -
- - return 0;
- -}
- -
- -#endif
- -
- #define SPLASH_DECL(_name) \
- extern u8 __splash_ ## _name ## _begin[]; \
- extern u8 __splash_ ## _name ## _end[]
- diff --git a/drivers/video/video_bmp.c b/drivers/video/video_bmp.c
- index 78de95607924..1f267d45812c 100644
- --- a/drivers/video/video_bmp.c
- +++ b/drivers/video/video_bmp.c
- @@ -267,7 +267,6 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y,
- enum video_format eformat;
- struct bmp_color_table_entry *palette;
- int hdr_size;
- - int ret;
-
- if (!bmp || !(bmp->header.signature[0] == 'B' &&
- bmp->header.signature[1] == 'M')) {
- @@ -461,11 +460,5 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y,
-
- video_damage(dev, x, y, width, height);
-
- - /* Find the position of the top left of the image in the framebuffer */
- - fb = (uchar *)(priv->fb + y * priv->line_length + x * bpix / 8);
- - ret = video_sync_copy(dev, start, fb);
- - if (ret)
- - return log_ret(ret);
- -
- return video_sync(dev, false);
- }
- diff --git a/include/video.h b/include/video.h
- index d2dabb66e9e6..44557457bf80 100644
- --- a/include/video.h
- +++ b/include/video.h
- @@ -353,43 +353,6 @@ void video_set_default_colors(struct udevice *dev, bool invert);
- */
- int video_default_font_height(struct udevice *dev);
-
- -#ifdef CONFIG_VIDEO_COPY
- -/**
- - * vidconsole_sync_copy() - Sync back to the copy framebuffer
- - *
- - * This ensures that the copy framebuffer has the same data as the framebuffer
- - * for a particular region. It should be called after the framebuffer is updated
- - *
- - * @from and @to can be in either order. The region between them is synced.
- - *
- - * @dev: Vidconsole device being updated
- - * @from: Start/end address within the framebuffer (->fb)
- - * @to: Other address within the frame buffer
- - * Return: 0 if OK, -EFAULT if the start address is before the start of the
- - * frame buffer start
- - */
- -int video_sync_copy(struct udevice *dev, void *from, void *to);
- -
- -/**
- - * video_sync_copy_all() - Sync the entire framebuffer to the copy
- - *
- - * @dev: Vidconsole device being updated
- - * Return: 0 (always)
- - */
- -int video_sync_copy_all(struct udevice *dev);
- -#else
- -static inline int video_sync_copy(struct udevice *dev, void *from, void *to)
- -{
- - return 0;
- -}
- -
- -static inline int video_sync_copy_all(struct udevice *dev)
- -{
- - return 0;
- -}
- -
- -#endif
- -
- #ifdef CONFIG_VIDEO_DAMAGE
- /**
- * video_damage() - Notify the video subsystem about screen updates.
- diff --git a/include/video_console.h b/include/video_console.h
- index 8b5928dc5ebb..8806d10f946d 100644
- --- a/include/video_console.h
- +++ b/include/video_console.h
- @@ -529,56 +529,4 @@ void vidconsole_list_fonts(struct udevice *dev);
- */
- int vidconsole_get_font_size(struct udevice *dev, const char **name, uint *sizep);
-
- -#ifdef CONFIG_VIDEO_COPY
- -/**
- - * vidconsole_sync_copy() - Sync back to the copy framebuffer
- - *
- - * This ensures that the copy framebuffer has the same data as the framebuffer
- - * for a particular region. It should be called after the framebuffer is updated
- - *
- - * @from and @to can be in either order. The region between them is synced.
- - *
- - * @dev: Vidconsole device being updated
- - * @from: Start/end address within the framebuffer (->fb)
- - * @to: Other address within the frame buffer
- - * Return: 0 if OK, -EFAULT if the start address is before the start of the
- - * frame buffer start
- - */
- -int vidconsole_sync_copy(struct udevice *dev, void *from, void *to);
- -
- -/**
- - * vidconsole_memmove() - Perform a memmove() within the frame buffer
- - *
- - * This handles a memmove(), e.g. for scrolling. It also updates the copy
- - * framebuffer.
- - *
- - * @dev: Vidconsole device being updated
- - * @dst: Destination address within the framebuffer (->fb)
- - * @src: Source address within the framebuffer (->fb)
- - * @size: Number of bytes to transfer
- - * Return: 0 if OK, -EFAULT if the start address is before the start of the
- - * frame buffer start
- - */
- -int vidconsole_memmove(struct udevice *dev, void *dst, const void *src,
- - int size);
- -#else
- -
- -#include <string.h>
- -
- -static inline int vidconsole_sync_copy(struct udevice *dev, void *from,
- - void *to)
- -{
- - return 0;
- -}
- -
- -static inline int vidconsole_memmove(struct udevice *dev, void *dst,
- - const void *src, int size)
- -{
- - memmove(dst, src, size);
- -
- - return 0;
- -}
- -
- -#endif
- -
- #endif
- diff --git a/test/dm/video.c b/test/dm/video.c
- index 119c43153165..9b7bb51a3dd9 100644
- --- a/test/dm/video.c
- +++ b/test/dm/video.c
- @@ -105,6 +105,7 @@ static int check_copy_frame_buffer(struct unit_test_state *uts,
- if (!IS_ENABLED(CONFIG_VIDEO_COPY))
- return 0;
-
- + video_sync(dev, false);
- ut_assertf(!memcmp(priv->fb, priv->copy_fb, priv->fb_size),
- "Copy framebuffer does not match fb");
-
- @@ -705,7 +706,7 @@ static int dm_test_video_copy(struct unit_test_state *uts)
- vidconsole_put_string(con, test_string);
- vidconsole_put_string(con, test_string);
- ut_asserteq(7589, compress_frame_buffer(uts, dev, false));
- - ut_asserteq(5278, compress_frame_buffer(uts, dev, true));
- + ut_asserteq(4127, compress_frame_buffer(uts, dev, true));
-
- return 0;
- }
- --
- 2.45.2
- From d0b64a4e493b665d7abafc185d88f533ebc27f2f Mon Sep 17 00:00:00 2001
- From: Alexander Graf <agraf@csgraf.de>
- Date: Tue, 3 Jan 2023 22:50:03 +0100
- Subject: [PATCH 12/13] video: Always compile cache flushing code
- The dcache flushing code path was conditional on ARM && !DCACHE config
- options. However, dcaches exist on other platforms as well and may need
- clearing if their driver requires it.
- Simplify the compile logic and always enable the dcache flush logic in
- the video core. That way, drivers can always rely on it to call the arch
- specific callbacks.
- This will increase code size for non-ARM platforms with CONFIG_VIDEO=y
- slightly.
- Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
- Signed-off-by: Alexander Graf <agraf@csgraf.de>
- Reviewed-by: Simon Glass <sjg@chromium.org>
- Link: https://lore.kernel.org/u-boot/20230821135111.3558478-13-alpernebiyasak@gmail.com/
- ---
- drivers/video/video-uclass.c | 12 +++++-------
- 1 file changed, 5 insertions(+), 7 deletions(-)
- diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c
- index 3b9b9fad0975..f050ed1f67cb 100644
- --- a/drivers/video/video-uclass.c
- +++ b/drivers/video/video-uclass.c
- @@ -377,6 +377,9 @@ static void video_flush_dcache(struct udevice *vid, bool use_copy)
- struct video_priv *priv = dev_get_uclass_priv(vid);
- ulong fb = use_copy ? (ulong)priv->copy_fb : (ulong)priv->fb;
-
- + if (CONFIG_IS_ENABLED(SYS_DCACHE_OFF))
- + return;
- +
- if (!priv->flush_dcache)
- return;
-
- @@ -442,17 +445,12 @@ int video_sync(struct udevice *vid, bool force)
- return ret;
- }
-
- - /*
- - * flush_dcache_range() is declared in common.h but it seems that some
- - * architectures do not actually implement it. Is there a way to find
- - * out whether it exists? For now, ARM is safe.
- - */
- -#if defined(CONFIG_ARM) && !CONFIG_IS_ENABLED(SYS_DCACHE_OFF)
- video_flush_dcache(vid, false);
-
- if (IS_ENABLED(CONFIG_VIDEO_COPY))
- video_flush_dcache(vid, true);
- -#elif defined(CONFIG_VIDEO_SANDBOX_SDL)
- +
- +#if defined(CONFIG_VIDEO_SANDBOX_SDL)
- static ulong last_sync;
-
- if (force || get_timer(last_sync) > 100) {
- --
- 2.45.2
- From e6b053a9d59d0b4ea0936edee5be2fadf0b8efc2 Mon Sep 17 00:00:00 2001
- From: Alexander Graf <agraf@csgraf.de>
- Date: Tue, 3 Jan 2023 22:50:04 +0100
- Subject: [PATCH 13/13] video: Enable VIDEO_DAMAGE for drivers that need it
- Some drivers call video_set_flush_dcache() to indicate that they want to
- have the dcache flushed for the frame buffer. These drivers benefit from
- our new video damage control, because we can reduce the amount of memory
- that gets flushed significantly.
- This patch enables video damage control for all device drivers that call
- video_set_flush_dcache() to make sure they benefit from it.
- Signed-off-by: Alexander Graf <agraf@csgraf.de>
- [Alper: Add to VIDEO_TIDSS, imply instead of select]
- Co-developed-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
- Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
- Reviewed-by: Simon Glass <sjg@chromium.org>
- Link: https://lore.kernel.org/u-boot/20230821135111.3558478-14-alpernebiyasak@gmail.com/
- ---
- arch/arm/mach-sunxi/Kconfig | 1 +
- drivers/video/Kconfig | 8 ++++++++
- drivers/video/exynos/Kconfig | 1 +
- drivers/video/imx/Kconfig | 1 +
- drivers/video/meson/Kconfig | 1 +
- drivers/video/rockchip/Kconfig | 1 +
- drivers/video/stm32/Kconfig | 1 +
- drivers/video/tegra20/Kconfig | 1 +
- drivers/video/tidss/Kconfig | 1 +
- 9 files changed, 16 insertions(+)
- diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
- index ddf9414b08e7..3c9745065bab 100644
- --- a/arch/arm/mach-sunxi/Kconfig
- +++ b/arch/arm/mach-sunxi/Kconfig
- @@ -863,6 +863,7 @@ config VIDEO_SUNXI
- depends on !SUNXI_GEN_NCAT2
- select VIDEO
- select DISPLAY
- + imply VIDEO_DAMAGE
- imply VIDEO_DT_SIMPLEFB
- default y
- ---help---
- diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
- index 88c6f8e68976..06d3ed8a736e 100644
- --- a/drivers/video/Kconfig
- +++ b/drivers/video/Kconfig
- @@ -499,6 +499,7 @@ config VIDEO_LCD_ANX9804
-
- config ATMEL_LCD
- bool "Atmel LCD panel support"
- + imply VIDEO_DAMAGE
- depends on ARCH_AT91
-
- config ATMEL_LCD_BGR555
- @@ -508,6 +509,7 @@ config ATMEL_LCD_BGR555
-
- config VIDEO_BCM2835
- bool "Display support for BCM2835"
- + imply VIDEO_DAMAGE
- help
- The graphics processor already sets up the display so this driver
- simply checks the resolution and then sets up the frame buffer with
- @@ -671,6 +673,7 @@ source "drivers/video/meson/Kconfig"
-
- config VIDEO_MVEBU
- bool "Armada XP LCD controller"
- + imply VIDEO_DAMAGE
- ---help---
- Support for the LCD controller integrated in the Marvell
- Armada XP SoC.
- @@ -705,6 +708,7 @@ config NXP_TDA19988
-
- config ATMEL_HLCD
- bool "Enable ATMEL video support using HLCDC"
- + imply VIDEO_DAMAGE
- help
- HLCDC supports video output to an attached LCD panel.
-
- @@ -781,6 +785,7 @@ source "drivers/video/tidss/Kconfig"
-
- config VIDEO_TEGRA124
- bool "Enable video support on Tegra124"
- + imply VIDEO_DAMAGE
- help
- Tegra124 supports many video output options including eDP and
- HDMI. At present only eDP is supported by U-Boot. This option
- @@ -795,6 +800,7 @@ source "drivers/video/imx/Kconfig"
-
- config VIDEO_MXS
- bool "Enable video support on i.MX28/i.MX6UL/i.MX7 SoCs"
- + imply VIDEO_DAMAGE
- help
- Enable framebuffer driver for i.MX28/i.MX6UL/i.MX7 processors
-
- @@ -857,6 +863,7 @@ config VIDEO_DW_MIPI_DSI
-
- config VIDEO_SIMPLE
- bool "Simple display driver for preconfigured display"
- + imply VIDEO_DAMAGE
- help
- Enables a simple generic display driver which utilizes the
- simple-framebuffer devicetree bindings.
- @@ -875,6 +882,7 @@ config VIDEO_DT_SIMPLEFB
-
- config VIDEO_MCDE_SIMPLE
- bool "Simple driver for ST-Ericsson MCDE with preconfigured display"
- + imply VIDEO_DAMAGE
- help
- Enables a simple display driver for ST-Ericsson MCDE
- (Multichannel Display Engine), which reads the configuration from
- diff --git a/drivers/video/exynos/Kconfig b/drivers/video/exynos/Kconfig
- index 599d19d5ecc2..a2cf752aac03 100644
- --- a/drivers/video/exynos/Kconfig
- +++ b/drivers/video/exynos/Kconfig
- @@ -12,6 +12,7 @@ config EXYNOS_DP
-
- config EXYNOS_FB
- bool "Exynos FIMD support"
- + imply VIDEO_DAMAGE
-
- config EXYNOS_MIPI_DSIM
- bool "Exynos MIPI DSI support"
- diff --git a/drivers/video/imx/Kconfig b/drivers/video/imx/Kconfig
- index 34e8b640595b..5db3e5c0499e 100644
- --- a/drivers/video/imx/Kconfig
- +++ b/drivers/video/imx/Kconfig
- @@ -2,6 +2,7 @@
- config VIDEO_IPUV3
- bool "i.MX IPUv3 Core video support"
- depends on VIDEO && (MX5 || MX6)
- + imply VIDEO_DAMAGE
- help
- This enables framebuffer driver for i.MX processors working
- on the IPUv3(Image Processing Unit) internal graphic processor.
- diff --git a/drivers/video/meson/Kconfig b/drivers/video/meson/Kconfig
- index 3c2d72d019b8..fcf486ca0a3a 100644
- --- a/drivers/video/meson/Kconfig
- +++ b/drivers/video/meson/Kconfig
- @@ -8,5 +8,6 @@ config VIDEO_MESON
- bool "Enable Amlogic Meson video support"
- depends on VIDEO
- select DISPLAY
- + imply VIDEO_DAMAGE
- help
- Enable Amlogic Meson Video Processing Unit video support.
- diff --git a/drivers/video/rockchip/Kconfig b/drivers/video/rockchip/Kconfig
- index 01804dcb1cc8..0f4550a29e38 100644
- --- a/drivers/video/rockchip/Kconfig
- +++ b/drivers/video/rockchip/Kconfig
- @@ -11,6 +11,7 @@
- menuconfig VIDEO_ROCKCHIP
- bool "Enable Rockchip Video Support"
- depends on VIDEO
- + imply VIDEO_DAMAGE
- help
- Rockchip SoCs provide video output capabilities for High-Definition
- Multimedia Interface (HDMI), Low-voltage Differential Signalling
- diff --git a/drivers/video/stm32/Kconfig b/drivers/video/stm32/Kconfig
- index 48066063e4c5..c354c402c288 100644
- --- a/drivers/video/stm32/Kconfig
- +++ b/drivers/video/stm32/Kconfig
- @@ -8,6 +8,7 @@
- menuconfig VIDEO_STM32
- bool "Enable STM32 video support"
- depends on VIDEO
- + imply VIDEO_DAMAGE
- help
- STM32 supports many video output options including RGB and
- DSI. This option enables these supports which can be used on
- diff --git a/drivers/video/tegra20/Kconfig b/drivers/video/tegra20/Kconfig
- index f5c4843e1191..2232b0b3ff53 100644
- --- a/drivers/video/tegra20/Kconfig
- +++ b/drivers/video/tegra20/Kconfig
- @@ -1,6 +1,7 @@
- config VIDEO_TEGRA20
- bool "Enable Display Controller support on Tegra20 and Tegra 30"
- depends on OF_CONTROL
- + imply VIDEO_DAMAGE
- help
- T20/T30 support video output to an attached LCD panel as well as
- other options such as HDMI. Only the LCD is supported in U-Boot.
- diff --git a/drivers/video/tidss/Kconfig b/drivers/video/tidss/Kconfig
- index 95086f3a5d66..3291b3ceb8d5 100644
- --- a/drivers/video/tidss/Kconfig
- +++ b/drivers/video/tidss/Kconfig
- @@ -11,6 +11,7 @@
- menuconfig VIDEO_TIDSS
- bool "Enable TIDSS video support"
- depends on VIDEO
- + imply VIDEO_DAMAGE
- help
- TIDSS supports video output options LVDS and
- DPI . This option enables these supports which can be used on
- --
- 2.45.2
|