From patchwork Mon Apr 25 07:59:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasyl Vavrychuk X-Patchwork-Id: 7090 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72E5CC54EFE for ; Mon, 25 Apr 2022 19:26:13 +0000 (UTC) Received: from repost01.tmes.trendmicro.eu (repost01.tmes.trendmicro.eu [18.185.115.31]) by mx.groups.io with SMTP id smtpd.web08.26839.1650873624550436630 for ; Mon, 25 Apr 2022 01:00:26 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@opensynergy.com header.s=tm-dkim-20210503141657 header.b=L8+azsJD; spf=pass (domain: opensynergy.com, ip: 18.185.115.31, mailfrom: vasyl.vavrychuk@opensynergy.com) Received: from 104.47.14.58_.trendmicro.com (unknown [172.21.163.172]) by repost01.tmes.trendmicro.eu (Postfix) with SMTP id D26EE10000653 for ; Mon, 25 Apr 2022 08:00:22 +0000 (UTC) X-TM-MAIL-RECEIVED-TIME: 1650873622.136000 X-TM-MAIL-UUID: 7f79fb24-0a69-4d7b-a35f-4949a22009cf Received: from EUR04-VI1-obe.outbound.protection.outlook.com (unknown [104.47.14.58]) by repre01.tmes.trendmicro.eu (Trend Micro Email Security) with ESMTPS id 2182E100024E9 for ; Mon, 25 Apr 2022 08:00:22 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kOt2mBdlC1IVq4Sc8kWalvjDB1it6LDKkyAmhTu0zD5JP89iYDFcN0jWrkGnyBoxWAcAdiQN9Shf1bnoajJQQY9d0yiDVrd+TGO1ow6Eop/BKjsBdj89EEbdUYKop9QJW9tjKtJRr2CemDf/AfKj4KzUbt4Ph5Wr+MufDRFrLChp2g4uTSd1ZO6sK/GXHVPBuAzttj1yrn0bF6ze4B7jvVkSqBetQKnAoJQOj5tvf7nnLN/YVBP5gueZTr7u1lsLZJ72NoknrTqWfnhGwm4hTDhWWJwWEYssvfA3KINoUk2qkMO/9en+A3QusW5wNHQFoh85YuQp1ymElZq4IEajBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=arHfyEZqinnsPzKufkSsE45zf+hOZ4B/piYJGybjBn4=; b=asJzUOg9W01kH4JG/u3cWa3PM/juPJbk/IVUJ4JovKqMYPJsEwT6ICOx03jTmGTKeYjfLAobwf4ts5uTMRoWpWTw4qF9cl7r7VxhWOihHJCSVH9xPAOtUnFw9HACELPQKooqV15qBVk0pfPco8e9Vjq6KubKgTzHTZq6V6jRzt0q1k3EmcWKIIUpQWMrLTGvo8Ap7QHBPJcXW+4mPD7BSVVIHzanfxAbspHR5pAD6yBDA6uyIJ7w8BM96Bpt/XUG3/tkPFTo5Q3DCTCvKSgmOThfzKqLm9oHBu/icOqzS54zqhh59dUxtqGRBfx3/1+ZLEUuxOGGBPOZUU0HTq/4bg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 217.66.60.4) smtp.rcpttodomain=lists.yoctoproject.org smtp.mailfrom=opensynergy.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=opensynergy.com; dkim=none (message not signed); arc=none X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 217.66.60.4) smtp.mailfrom=opensynergy.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=opensynergy.com; Received-SPF: Pass (protection.outlook.com: domain of opensynergy.com designates 217.66.60.4 as permitted sender) receiver=protection.outlook.com; client-ip=217.66.60.4; helo=SR-MAIL-03.open-synergy.com; From: Vasyl Vavrychuk To: yocto@lists.yoctoproject.org Cc: Vasyl Vavrychuk Subject: [psplash][RFC PATCH 01/14] Trim trailing spaces Date: Mon, 25 Apr 2022 10:59:41 +0300 Message-Id: <20220425075954.10427-2-vasyl.vavrychuk@opensynergy.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220425075954.10427-1-vasyl.vavrychuk@opensynergy.com> References: <20220425075954.10427-1-vasyl.vavrychuk@opensynergy.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 63787c9d-fb90-4684-6269-08da2691a44c X-MS-TrafficTypeDiagnostic: AM9PR04MB8340:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VQvvRJJJBk0dyGx44Ffp3Mrn8XLQloVNpdAEa/d0VkuJ98bD7sXZB+SHlQG4LPEYp3o2c3EqYDIkHqwBLp2QBJpOE8NV5SPqeLLEtvlEWMdawGeJwcyN2vxdtSAOlX8sj6FemIBQUOc/4AW9E7gWRC1TLh1YL8O5Sc2yJby5gX4+/6iDup3RC/FwKvdRo8rTjo+ykDAk0/9czNyoHxJX/+5/5CsDkNvw3Y6lrmXY4Ja80Y4SMCJqjpcUV+TXywilJpb83LbxGcJ0lqhe2ZMSaFutHNLgWLy4GLpN94RsWASHohMItxOVYfa3/GEdiPVMTUKe5WvlVJMjQ0RgbpX8AO5MXPUPffDcswiZvyYO4riZ8RvFV92LriueHXmXsWCsS42fRt+Zogqdxw99p6QQxy3MK9VOToZIrBzxeR2xNndyfzW88O7HxDmnNH5IC1Li0uwiCIpFRpxz9l2F1rPQtjFLz73HmUOjCNkc0JNgyMNzOXtT8CTi+FTU3P3peloZrr4VVBBadVlaOVCsR/OvwTrHCnIUxuKB3UFet+vNF+3mHmVKqzNxLJkUvbhdulOciroXyvb9M9BspBXPRi8tmzCuUDKE7n1rBKVkXc33m/sz8FMNYq9XSFXXzAuQZf72GQw6609MqwEwXsb7hUZAzmVkaqnYIMqt4OTxqB5sEBLWecNVbKPubI8wstHSyTMY X-Forefront-Antispam-Report: CIP:217.66.60.4;CTRY:DE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SR-MAIL-03.open-synergy.com;PTR:mx1.opensynergy.com;CAT:NONE;SFS:(13230001)(136003)(396003)(376002)(39830400003)(346002)(36840700001)(46966006)(70206006)(70586007)(82310400005)(2906002)(81166007)(6916009)(316002)(8676002)(42186006)(4326008)(30864003)(44832011)(5660300002)(8936002)(508600001)(36860700001)(86362001)(107886003)(1076003)(186003)(36756003)(26005)(83380400001)(336012)(2616005)(40480700001)(47076005);DIR:OUT;SFP:1102; X-OriginatorOrg: opensynergy.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2022 08:00:19.4148 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 63787c9d-fb90-4684-6269-08da2691a44c X-MS-Exchange-CrossTenant-Id: 800fae25-9b1b-4edc-993d-c939c4e84a64 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=800fae25-9b1b-4edc-993d-c939c4e84a64;Ip=[217.66.60.4];Helo=[SR-MAIL-03.open-synergy.com] X-MS-Exchange-CrossTenant-AuthSource: AM6EUR05FT009.eop-eur05.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8340 X-TM-AS-ERS: 104.47.14.58-0.0.0.0 X-TMASE-Version: StarCloud-1.3-8.8.1001-26854.006 X-TMASE-Result: 10--15.398400-4.000000 X-TMASE-MatchedRID: 4qV+NBuSyTCRmYpU4vHLUk7nLUqYrlslFIuBIWrdOePfUZT83lbkEMs0 A8Och09B72CHleXBH4Mug4wH5ynJhrqIXLlnBtio9DGkDtq4vAz4uJ1REX4MHWu8v+VuTbszZ8s oRbuqWwcoYeKRT/uGFMuHgW1QxPEa3c6pD8uG0BV3IYxRexpgADAuMzu3eJGjIZvN+3iLe807h1 0itb3JFfmNDPvp636/BPT3/NC+4NKg8gEDnq22YxMxKDqgAFSzk45XNF39dU48cwBuO6HB3wcE3 AwiiNlyqjNOPAGUK/apKt810hIw5W5j5yYKSZJ9tw+xHnsmQjMzNsXWBvGVBhh1mpCXNVC8Bk0s RysFrTAAcM5TB53eImb8g1GpLkmuYDVHXGJx4TvwlvzzUUaf2WKO5oaZLIN/LX3qyf3ewG8tPHt LgxWl9uaK4gXXzQ8VuXFEQJaCEz7+OhQWBlKflRRFJJyf5BJe3QfwsVk0UbtuRXh7bFKB7umgcz IC6sNnB1AsMJxqqFttPwr1iVZ8RsKlKzjDR72cNkUSDDq742k= X-TMASE-XGENCLOUD: 661a9eba-753d-4609-83f3-e1b39e15d8b0-0-0-200-0 X-TM-Deliver-Signature: B33B9A816B7EE4F6042B00803CFE4FAD DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=opensynergy.com; s=TM-DKIM-20210503141657; t=1650873622; bh=fQ4BdbyxLy5n35tvUvpPmbmIUSs79r7Zm4LlSguMKcY=; l=14715; h=From:To:Date; b=L8+azsJDKY2c16HJUGN+yzXwXvRZfi7tVcOb3cS46hqhzEdQ6aTmeADIKgnRdZi84 shY1+sqB0XQghtGBedaITQSi+uo2vcd87cy+CPPD5iqAClrQ4KrfaUfMtVKWUpuYZc s7bKBdz9Bs6BlL6x/YZIAQvnmtrpiasBslnMnwaMUWyWjCD2vCQWXUNuS0+rBkZOW6 5dGLdpKPtymkDT+oClnwOzbbDfvT02NKyKpXG0Zgg3/5S7ounn3krgVzzRmDUrL7bI DcjWFUjANNJSVeCPgqYV3MeB1ntI3MKGGVw0SBG+wejfDJV3kQN3wljMuT1B9Zvq97 VkDwRLev5IVIA== List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 25 Apr 2022 19:26:13 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto/message/56859 Signed-off-by: Vasyl Vavrychuk --- psplash-console.c | 34 +++++++++++----------- psplash-console.h | 8 ++--- psplash-fb.c | 4 +-- psplash-fb.h | 34 +++++++++++----------- psplash-write.c | 14 ++++----- psplash.c | 74 +++++++++++++++++++++++------------------------ psplash.h | 4 +-- 7 files changed, 86 insertions(+), 86 deletions(-) diff --git a/psplash-console.c b/psplash-console.c index 3a40620..c00c6fe 100644 --- a/psplash-console.c +++ b/psplash-console.c @@ -1,5 +1,5 @@ -/* - * pslash - a lightweight framebuffer splashscreen for embedded devices. +/* + * pslash - a lightweight framebuffer splashscreen for embedded devices. * * Copyright (c) 2006 Matthew Allum * @@ -27,12 +27,12 @@ vt_request (int UNUSED(sig)) perror("Error cannot switch away from console"); Visible = 0; - /* FIXME: - * We likely now want to signal the main loop as to exit + /* FIXME: + * We likely now want to signal the main loop as to exit * and we've now likely switched to the X tty. Note, this * seems to happen anyway atm due to select() call getting * a signal interuption error - not sure if this is really - * reliable however. + * reliable however. */ } else @@ -49,7 +49,7 @@ psplash_console_ignore_switches (void) { struct sigaction act; struct vt_mode vt_mode; - + if (ioctl(ConsoleFd, VT_GETMODE, &vt_mode) < 0) { perror("Error VT_SETMODE failed"); @@ -60,7 +60,7 @@ psplash_console_ignore_switches (void) sigemptyset (&act.sa_mask); act.sa_flags = 0; sigaction (SIGUSR1, &act, 0); - + vt_mode.mode = VT_AUTO; vt_mode.relsig = 0; vt_mode.acqsig = 0; @@ -74,7 +74,7 @@ psplash_console_handle_switches (void) { struct sigaction act; struct vt_mode vt_mode; - + if (ioctl(ConsoleFd, VT_GETMODE, &vt_mode) < 0) { perror("Error VT_SETMODE failed"); @@ -85,7 +85,7 @@ psplash_console_handle_switches (void) sigemptyset (&act.sa_mask); act.sa_flags = 0; sigaction (SIGUSR1, &act, 0); - + vt_mode.mode = VT_PROCESS; vt_mode.relsig = SIGUSR1; vt_mode.acqsig = SIGUSR1; @@ -94,8 +94,8 @@ psplash_console_handle_switches (void) perror("Error VT_SETMODE failed"); } -void -psplash_console_switch (void) +void +psplash_console_switch (void) { char vtname[10]; int fd; @@ -114,9 +114,9 @@ psplash_console_switch (void) close(fd); return; } - + close(fd); - + sprintf(vtname,"/dev/tty%d", VTNum); if ((ConsoleFd = open(vtname, O_RDWR|O_NDELAY, 0)) < 0) @@ -134,12 +134,12 @@ psplash_console_switch (void) if (ioctl(ConsoleFd, VT_ACTIVATE, VTNum) != 0) perror("Error VT_ACTIVATE failed"); - + if (ioctl(ConsoleFd, VT_WAITACTIVE, VTNum) != 0) perror("Error VT_WAITACTIVE failed\n"); psplash_console_handle_switches (); - + if (ioctl(ConsoleFd, KDSETMODE, KD_GRAPHICS) < 0) perror("Error KDSETMODE KD_GRAPHICS failed\n"); @@ -156,7 +156,7 @@ psplash_console_reset (void) return; /* Back to text mode */ - ioctl(ConsoleFd, KDSETMODE, KD_TEXT); + ioctl(ConsoleFd, KDSETMODE, KD_TEXT); psplash_console_ignore_switches (); @@ -175,7 +175,7 @@ psplash_console_reset (void) /* Cleanup */ - close(ConsoleFd); + close(ConsoleFd); if ((fd = open ("/dev/tty0", O_RDWR|O_NDELAY, 0)) >= 0) { diff --git a/psplash-console.h b/psplash-console.h index c893bf2..ad51ef2 100644 --- a/psplash-console.h +++ b/psplash-console.h @@ -1,5 +1,5 @@ -/* - * pslash - a lightweight framebuffer splashscreen for embedded devices. +/* + * pslash - a lightweight framebuffer splashscreen for embedded devices. * * Copyright (c) 2006 Matthew Allum * @@ -10,8 +10,8 @@ #ifndef _HAVE_PSPLASH_CONSOLE_H #define _HAVE_PSPLASH_CONSOLE_H -void -psplash_console_switch (void); +void +psplash_console_switch (void); void psplash_console_reset (void); diff --git a/psplash-fb.c b/psplash-fb.c index 2babb5f..1d2d7db 100644 --- a/psplash-fb.c +++ b/psplash-fb.c @@ -429,13 +429,13 @@ psplash_fb_plot_pixel (PSplashFB *fb, { case 32: *(volatile uint32_t *) (fb->bdata + off) - = ((red >> (8 - fb->red_length)) << fb->red_offset) + = ((red >> (8 - fb->red_length)) << fb->red_offset) | ((green >> (8 - fb->green_length)) << fb->green_offset) | ((blue >> (8 - fb->blue_length)) << fb->blue_offset); break; case 16: *(volatile uint16_t *) (fb->bdata + off) - = ((red >> (8 - fb->red_length)) << fb->red_offset) + = ((red >> (8 - fb->red_length)) << fb->red_offset) | ((green >> (8 - fb->green_length)) << fb->green_offset) | ((blue >> (8 - fb->blue_length)) << fb->blue_offset); break; diff --git a/psplash-fb.h b/psplash-fb.h index 16e2b20..eafa293 100644 --- a/psplash-fb.h +++ b/psplash-fb.h @@ -1,5 +1,5 @@ -/* - * pslash - a lightweight framebuffer splashscreen for embedded devices. +/* + * pslash - a lightweight framebuffer splashscreen for embedded devices. * * Copyright (c) 2006 Matthew Allum * @@ -20,11 +20,11 @@ enum RGBMode { typedef struct PSplashFB { - int fd; + int fd; struct fb_var_screeninfo fb_var; - struct termios save_termios; - int type; - int visual; + struct termios save_termios; + int type; + int visual; int width, height; int bpp; int stride; @@ -56,20 +56,20 @@ PSplashFB* psplash_fb_new (int angle, int fbdev_id); void -psplash_fb_draw_rect (PSplashFB *fb, - int x, - int y, - int width, +psplash_fb_draw_rect (PSplashFB *fb, + int x, + int y, + int width, int height, uint8 red, uint8 green, uint8 blue); void -psplash_fb_draw_image (PSplashFB *fb, - int x, - int y, - int img_width, +psplash_fb_draw_image (PSplashFB *fb, + int x, + int y, + int img_width, int img_height, int img_bytes_pre_pixel, int img_rowstride, @@ -82,9 +82,9 @@ psplash_fb_text_size (int *width, const char *text); void -psplash_fb_draw_text (PSplashFB *fb, - int x, - int y, +psplash_fb_draw_text (PSplashFB *fb, + int x, + int y, uint8 red, uint8 green, uint8 blue, diff --git a/psplash-write.c b/psplash-write.c index a12467a..eee0ea3 100644 --- a/psplash-write.c +++ b/psplash-write.c @@ -1,5 +1,5 @@ -/* - * pslash - a lightweight framebuffer splashscreen for embedded devices. +/* + * pslash - a lightweight framebuffer splashscreen for embedded devices. * * Copyright (c) 2006 Matthew Allum * @@ -19,7 +19,7 @@ #include #include "psplash.h" -int main(int argc, char **argv) +int main(int argc, char **argv) { char *rundir; int pipe_fd; @@ -29,17 +29,17 @@ int main(int argc, char **argv) if (!rundir) rundir = "/run"; - if (argc!=2) + if (argc!=2) { fprintf(stderr, "Wrong number of arguments\n"); exit(-1); } - + chdir(rundir); - + if ((pipe_fd = open (PSPLASH_FIFO,O_WRONLY|O_NONBLOCK)) == -1) { - /* Silently error out instead of covering the boot process in + /* Silently error out instead of covering the boot process in errors when psplash has exitted due to a VC switch */ /* perror("Error unable to open fifo"); */ exit (-1); diff --git a/psplash.c b/psplash.c index ee1af6b..838ac13 100644 --- a/psplash.c +++ b/psplash.c @@ -1,9 +1,9 @@ -/* - * pslash - a lightweight framebuffer splashscreen for embedded devices. +/* + * pslash - a lightweight framebuffer splashscreen for embedded devices. * * Copyright (c) 2006 Matthew Allum * - * Parts of this file ( fifo handling ) based on 'usplash' copyright + * Parts of this file ( fifo handling ) based on 'usplash' copyright * Matthew Garret. * * SPDX-License-Identifier: GPL-2.0-or-later @@ -46,15 +46,15 @@ psplash_draw_msg (PSplashFB *fb, const char *msg) /* Clear */ - psplash_fb_draw_rect (fb, - 0, - SPLIT_LINE_POS(fb) - h, + psplash_fb_draw_rect (fb, + 0, + SPLIT_LINE_POS(fb) - h, fb->width, h, PSPLASH_BACKGROUND_COLOR); psplash_fb_draw_text (fb, - (fb->width-w)/2, + (fb->width-w)/2, SPLIT_LINE_POS(fb) - h, PSPLASH_TEXT_COLOR, &FONT_DEF, @@ -70,13 +70,13 @@ psplash_draw_progress (PSplashFB *fb, int value) /* 4 pix border */ x = ((fb->width - BAR_IMG_WIDTH)/2) + 4 ; y = SPLIT_LINE_POS(fb) + 4; - width = BAR_IMG_WIDTH - 8; + width = BAR_IMG_WIDTH - 8; height = BAR_IMG_HEIGHT - 8; if (value > 0) { barwidth = (CLAMP(value,0,100) * width) / 100; - psplash_fb_draw_rect (fb, x + barwidth, y, + psplash_fb_draw_rect (fb, x + barwidth, y, width - barwidth, height, PSPLASH_BAR_BACKGROUND_COLOR); psplash_fb_draw_rect (fb, x, y, barwidth, @@ -85,7 +85,7 @@ psplash_draw_progress (PSplashFB *fb, int value) else { barwidth = (CLAMP(-value,0,100) * width) / 100; - psplash_fb_draw_rect (fb, x, y, + psplash_fb_draw_rect (fb, x, y, width - barwidth, height, PSPLASH_BAR_BACKGROUND_COLOR); psplash_fb_draw_rect (fb, x + width - barwidth, @@ -93,18 +93,18 @@ psplash_draw_progress (PSplashFB *fb, int value) PSPLASH_BAR_COLOR); } - DBG("value: %i, width: %i, barwidth :%i\n", value, + DBG("value: %i, width: %i, barwidth :%i\n", value, width, barwidth); } #endif /* PSPLASH_SHOW_PROGRESS_BAR */ -static int +static int parse_command (PSplashFB *fb, char *string) { char *command; DBG("got cmd %s", string); - + if (strcmp(string,"QUIT") == 0) return 1; @@ -116,7 +116,7 @@ parse_command (PSplashFB *fb, char *string) if (arg) psplash_draw_msg (fb, arg); - } + } #ifdef PSPLASH_SHOW_PROGRESS_BAR else if (!strcmp(command,"PROGRESS")) { @@ -124,9 +124,9 @@ parse_command (PSplashFB *fb, char *string) if (arg) psplash_draw_progress (fb, atoi(arg)); - } + } #endif - else if (!strcmp(command,"QUIT")) + else if (!strcmp(command,"QUIT")) { return 1; } @@ -135,8 +135,8 @@ parse_command (PSplashFB *fb, char *string) return 0; } -void -psplash_main (PSplashFB *fb, int pipe_fd, int timeout) +void +psplash_main (PSplashFB *fb, int pipe_fd, int timeout) { int err; ssize_t length = 0; @@ -154,14 +154,14 @@ psplash_main (PSplashFB *fb, int pipe_fd, int timeout) end = command; - while (1) + while (1) { - if (timeout != 0) + if (timeout != 0) err = select(pipe_fd+1, &descriptors, NULL, NULL, &tv); else err = select(pipe_fd+1, &descriptors, NULL, NULL, NULL); - - if (err <= 0) + + if (err <= 0) { /* if (errno == EINTR) @@ -169,10 +169,10 @@ psplash_main (PSplashFB *fb, int pipe_fd, int timeout) */ return; } - + length += read (pipe_fd, end, sizeof(command) - (end - command)); - if (length == 0) + if (length == 0) { /* Reopen to see if there's anything more for us */ close(pipe_fd); @@ -208,10 +208,10 @@ psplash_main (PSplashFB *fb, int pipe_fd, int timeout) out: end = &command[length]; - + tv.tv_sec = timeout; tv.tv_usec = 0; - + FD_ZERO(&descriptors); FD_SET(pipe_fd,&descriptors); } @@ -219,8 +219,8 @@ psplash_main (PSplashFB *fb, int pipe_fd, int timeout) return; } -int -main (int argc, char** argv) +int +main (int argc, char** argv) { char *rundir; int pipe_fd, i = 0, angle = 0, fbdev_id = 0, ret = 0; @@ -253,8 +253,8 @@ main (int argc, char** argv) } fail: - fprintf(stderr, - "Usage: %s [-n|--no-console-switch][-a|--angle <0|90|180|270>][-f|--fbdev <0..9>]\n", + fprintf(stderr, + "Usage: %s [-n|--no-console-switch][-a|--angle <0|90|180|270>][-f|--fbdev <0..9>]\n", argv[0]); exit(-1); } @@ -268,7 +268,7 @@ main (int argc, char** argv) if (mkfifo(PSPLASH_FIFO, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP)) { - if (errno!=EEXIST) + if (errno!=EEXIST) { perror("mkfifo"); exit(-1); @@ -276,8 +276,8 @@ main (int argc, char** argv) } pipe_fd = open (PSPLASH_FIFO,O_RDONLY|O_NONBLOCK); - - if (pipe_fd==-1) + + if (pipe_fd==-1) { perror("pipe open"); exit(-2); @@ -301,8 +301,8 @@ main (int argc, char** argv) PSPLASH_BACKGROUND_COLOR); /* Draw the Poky logo */ - psplash_fb_draw_image (fb, - (fb->width - POKY_IMG_WIDTH)/2, + psplash_fb_draw_image (fb, + (fb->width - POKY_IMG_WIDTH)/2, #if PSPLASH_IMG_FULLSCREEN (fb->height - POKY_IMG_HEIGHT)/2, #else @@ -317,8 +317,8 @@ main (int argc, char** argv) #ifdef PSPLASH_SHOW_PROGRESS_BAR /* Draw progress bar border */ - psplash_fb_draw_image (fb, - (fb->width - BAR_IMG_WIDTH)/2, + psplash_fb_draw_image (fb, + (fb->width - BAR_IMG_WIDTH)/2, SPLIT_LINE_POS(fb), BAR_IMG_WIDTH, BAR_IMG_HEIGHT, diff --git a/psplash.h b/psplash.h index 1c42ec7..3739ca3 100644 --- a/psplash.h +++ b/psplash.h @@ -1,5 +1,5 @@ -/* - * pslash - a lightweight framebuffer splashscreen for embedded devices. +/* + * pslash - a lightweight framebuffer splashscreen for embedded devices. * * Copyright (c) 2006 Matthew Allum * From patchwork Mon Apr 25 07:59:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasyl Vavrychuk X-Patchwork-Id: 7086 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72658C54EFD for ; Mon, 25 Apr 2022 19:26:13 +0000 (UTC) Received: from repost01.tmes.trendmicro.eu (repost01.tmes.trendmicro.eu [18.185.115.7]) by mx.groups.io with SMTP id smtpd.web10.26689.1650873625220789883 for ; Mon, 25 Apr 2022 01:00:26 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@opensynergy.com header.s=tm-dkim-20210503141657 header.b=xHtxL82+; spf=pass (domain: opensynergy.com, ip: 18.185.115.7, mailfrom: vasyl.vavrychuk@opensynergy.com) Received: from 104.47.18.106_.trendmicro.com (unknown [172.21.182.42]) by repost01.tmes.trendmicro.eu (Postfix) with SMTP id 3FD17100022F5 for ; Mon, 25 Apr 2022 08:00:23 +0000 (UTC) X-TM-MAIL-RECEIVED-TIME: 1650873621.646000 X-TM-MAIL-UUID: 67331029-592d-4d51-ba4b-ecbc11936600 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (unknown [104.47.18.106]) by repre01.tmes.trendmicro.eu (Trend Micro Email Security) with ESMTPS id 9DFE210002181 for ; Mon, 25 Apr 2022 08:00:21 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SxVvTQoWwDEto0wp+Clna/t/E0RLRfDaPgSdW6WmdddXlu2UqBpV8v3IHmYr5KJTqWY0sNIc+HgNFaDGIkNKNZuQ34VsSF/zo39T1Qt+CefZLRFyYBkNvL7t42ZsNvj0CEPUCTKm3/BEODt4HclsThrn+8GFQHTSqQMHKS+DXMWMjJfqnKsReVMSd9Rd3Uc/IgJhAXEoiA4Nzc4XS5GHkisfFQ4SpgaIaXWLUZgwYUFs1h2jN+6P1ibRU6eBIfCP7yyiXs0SAxAWf6QnTcEGCUmKU+eQKL1eU0tbgoxkklYmXENopcu9cdUhysgtV/iD6aSfu8OC3hYQN5Up4u49mQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=90J5/kXnD3pPG6MbwHCxv/ucmZZsGgUsRwXSbImZ5ro=; b=OMvzr2+08ToqqiH2Tj1OdlNTnVAsMxY5EFG5bmpN0Miq0yvrVGkgLh00xp4zGK7Z9zYkGamWNkDw7fJuNJebbg6vSEgusxXPyeI/VwIhfwb4IHFHZJ7v/SEQqdeLAvuK5uCtXI7mzvYqwBF7zpw7Qr93kPlTKOvwqkvxMYxUCNbBcD3doTVUhn6woYKYNQQWRDY4GoLW2RtktiDlc54/JTR7FNWOdTcGNaDVGtFw+fPQrzHeVMWJy0p0LOH7Vxv3Hpd1Nf5Ewfbj3HBkruu9oRR7hSa3g8z3Blk2b/XLVCFuBa02L3Vgp7D7IfmMsr/AXfbFs+S5Lw8rby8q5VVjkg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 217.66.60.4) smtp.rcpttodomain=lists.yoctoproject.org smtp.mailfrom=opensynergy.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=opensynergy.com; dkim=none (message not signed); arc=none X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 217.66.60.4) smtp.mailfrom=opensynergy.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=opensynergy.com; Received-SPF: Pass (protection.outlook.com: domain of opensynergy.com designates 217.66.60.4 as permitted sender) receiver=protection.outlook.com; client-ip=217.66.60.4; helo=SR-MAIL-03.open-synergy.com; From: Vasyl Vavrychuk To: yocto@lists.yoctoproject.org Cc: Vasyl Vavrychuk Subject: [psplash][RFC PATCH 02/14] Fix 'unused-result' warnings Date: Mon, 25 Apr 2022 10:59:42 +0300 Message-Id: <20220425075954.10427-3-vasyl.vavrychuk@opensynergy.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220425075954.10427-1-vasyl.vavrychuk@opensynergy.com> References: <20220425075954.10427-1-vasyl.vavrychuk@opensynergy.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 97f0de4e-590e-4e35-db23-08da2691a46e X-MS-TrafficTypeDiagnostic: AM9PR04MB8684:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: q8BV829HNNDcYLag+b9PNamZhGl5aTRhJ/V8kHqRFMh63L+rzijPGSbn7j6DI1C0Mmor1A0cp1vNDG0sC/n324bGDNpN/4NQ6m0HTN7RPuz28csbw9j45tQ7BEEKmxJfeOv9VpdeOCpQUO5NHnH3mW/MkiLudDCq1OQbwbN3wK3v/uyluQsccoH7MuPjmceXFRJIbBC6HJYgVTRxEbFKp484+0IZpLHG/q8I4I2uHQQ4lFyAIk7tT/kTyTfK5npm2ZZozutmVQ6KhQmaP42OQh35fBaccYCtSJYYM1utxBWuhjASfwLOUJMGpgUy5bvWBbVxYor232tK550kRYbMJuTKme8Wreg9lqFGn+DHvsa/e3uv07HFKjAqyFXxHWGT/i6drbEgjAhoHaKjv/uVhlQRe/4+6au/STr61RcF7XE60cHUJcpVE+d7P0/vjNwnpCuWouMjgknuzuUVjFP6VNpLSuonzXd0RGhICz0itRldPqyu4ojIQhASxrB9EBiCEKx8OGD/XEOZvg4MPja2c3/LL7ECtRyZ6tvuwuUsEWMKB/H3795UZcSu4Z4JPJ9fqmYj+WwU47z8fdHJR6PT3EcUPAHwe78dvhnDN7IGpibp0hCwKN8WYwqOWBWAqLgoEUOYtbYVvdvkfCbLyMo7r9pmrF6wDZwfMx+Yop95KraTgNu+TPEIjpyCRHpBxgLI X-Forefront-Antispam-Report: CIP:217.66.60.4;CTRY:DE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SR-MAIL-03.open-synergy.com;PTR:mx1.opensynergy.com;CAT:NONE;SFS:(13230001)(376002)(346002)(136003)(396003)(39830400003)(46966006)(36840700001)(83380400001)(8676002)(70586007)(4326008)(70206006)(2616005)(316002)(6916009)(86362001)(42186006)(186003)(1076003)(47076005)(336012)(508600001)(107886003)(81166007)(26005)(36860700001)(8936002)(5660300002)(40480700001)(44832011)(36756003)(2906002)(82310400005);DIR:OUT;SFP:1102; X-OriginatorOrg: opensynergy.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2022 08:00:19.6407 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 97f0de4e-590e-4e35-db23-08da2691a46e X-MS-Exchange-CrossTenant-Id: 800fae25-9b1b-4edc-993d-c939c4e84a64 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=800fae25-9b1b-4edc-993d-c939c4e84a64;Ip=[217.66.60.4];Helo=[SR-MAIL-03.open-synergy.com] X-MS-Exchange-CrossTenant-AuthSource: AM6EUR05FT039.eop-eur05.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8684 X-TM-AS-ERS: 104.47.18.106-0.0.0.0 X-TMASE-Version: StarCloud-1.3-8.8.1001-26854.006 X-TMASE-Result: 10-0.189500-4.000000 X-TMASE-MatchedRID: QxNw5Kr7aBfxUWwkULk0uancG1vVsfbQCZa9cSpBObnAuQ0xDMaXkH4q tYI9sRE/xRuqz2yp6boFURGsnD81bDwKObdstb0dCtzGvPCy/m6tOrovcQWGr9+tinHBPzXWDLb Bq7zk/lc/Aw0eUOPlqhzK5Uk364Hv74MThWsvfJgTMSg6oABUs7JEo6RFXaMBR6RHdVK85hWsHU lIAOKuuOgc6mX1lwNHkRoxEQkO3VF1H8bw68oiDwtuKBGekqUpbGVEmIfjf3u4pbD2Y4zp0dL1U sw8G5+oqrFYVfRv5U0IqcDENxkrxHwpkLs4Pfs+ X-TMASE-XGENCLOUD: 0471d38d-03bf-4391-b04f-862bf9b541fd-0-0-200-0 X-TM-Deliver-Signature: 9F5C26AF83533B7059DC3823774AE249 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=opensynergy.com; s=TM-DKIM-20210503141657; t=1650873623; bh=TcrXXOXfg4+vr2Oh/xrw0CQC/Jodm0o/J8DUTFKvoyw=; l=3576; h=From:To:Date; b=xHtxL82+Cw9Q2pFeyE44irvpdEtHx0uhCeI2xp4uX+P/UNYz8WVnvgJh0U1DmrtUg dh39lzhAh8Tx0CRIRK9OblxnhbcV9AEbtt/YNeBeDeKaBaNwRdH7qjDt3oTeFgYpv6 twFqftnO7lyuYwZgPz7CoiXSmIeleg9Na6t6bP+LgCcQ6MIyCWai/oiOMV9j+BIn5c DUGrjpdBOnATmatJKML813kmgnDAHkTQd6vz6xqU9tttjROY4c0yCozm6I5mfF1adf mNmTgIVStoobV16/KJ9A/biKdDfWlwfTzbU3CeW83jMZ3FYDgYYfV1yh40JzKVykRY Cif2u5kYEZwuA== List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 25 Apr 2022 19:26:13 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto/message/56860 This fixes warnings such as: ignoring return value of 'chdir', declared with attribute warn_unused_result [-Wunused-result] Signed-off-by: Vasyl Vavrychuk --- psplash-systemd.c | 36 +++++++++++++++++++++++++++++++++--- psplash-write.c | 23 ++++++++++++++++++----- psplash.c | 5 ++++- 3 files changed, 55 insertions(+), 9 deletions(-) diff --git a/psplash-systemd.c b/psplash-systemd.c index 840bd4e..dcf7e61 100644 --- a/psplash-systemd.c +++ b/psplash-systemd.c @@ -32,6 +32,7 @@ int get_progress(void) int r; char buffer[20]; int len; + ssize_t written; /* Connect to the system bus */ r = sd_bus_new(&bus); @@ -71,11 +72,36 @@ int get_progress(void) current_progress = progress; len = snprintf(buffer, 20, "PROGRESS %d", (int)(current_progress * 100)); - write(pipe_fd, buffer, len + 1); + written = write(pipe_fd, buffer, len + 1); + if (written == -1) { + /* EPIPE could mean that psplash detected boot complete sooner + then psplash-systemd and exited */ + if (errno != EPIPE) { + perror("write"); + r = -1; + goto finish; + } + } else if (written < len + 1) { + fprintf(stderr, "Wrote %zd bytes, less then expected %d bytes\n", + written, len + 1); + r = -1; + goto finish; + } if (progress == 1.0) { printf("Systemd reported progress of 1.0, quit psplash.\n"); - write(pipe_fd, "QUIT", 5); + written = write(pipe_fd, "QUIT", 5); + if (written == -1) { + /* EPIPE could mean that psplash detected boot complete + sooner then psplash-systemd and exited */ + if (errno != EPIPE) { + perror("write"); + r = -1; + goto finish; + } + } else if (written < 5) + fprintf(stderr, "Wrote %zd bytes, less then expected 5 bytes\n", + written); r = -1; } @@ -123,7 +149,11 @@ int main() if (!rundir) rundir = "/run"; - chdir(rundir); + r = chdir(rundir); + if (r < 0) { + perror("chdir"); + goto finish; + } if ((pipe_fd = open (PSPLASH_FIFO,O_WRONLY|O_NONBLOCK)) == -1) { fprintf(stderr, "Error unable to open fifo"); diff --git a/psplash-write.c b/psplash-write.c index eee0ea3..16b87e1 100644 --- a/psplash-write.c +++ b/psplash-write.c @@ -21,8 +21,10 @@ int main(int argc, char **argv) { - char *rundir; - int pipe_fd; + char *rundir; + int pipe_fd; + size_t count; + ssize_t written; rundir = getenv("PSPLASH_FIFO_DIR"); @@ -35,7 +37,10 @@ int main(int argc, char **argv) exit(-1); } - chdir(rundir); + if (chdir(rundir)) { + perror("chdir"); + exit(-1); + } if ((pipe_fd = open (PSPLASH_FIFO,O_WRONLY|O_NONBLOCK)) == -1) { @@ -45,8 +50,16 @@ int main(int argc, char **argv) exit (-1); } - write(pipe_fd, argv[1], strlen(argv[1])+1); + count = strlen(argv[1]) + 1; + written = write(pipe_fd, argv[1], count); + if (written == -1) { + perror("write"); + exit(-1); + } else if ((size_t)written < count) { + fprintf(stderr, "Wrote %zd bytes, less then expected %zu bytes\n", + written, count); + exit(-1); + } return 0; } - diff --git a/psplash.c b/psplash.c index 838ac13..62244ba 100644 --- a/psplash.c +++ b/psplash.c @@ -264,7 +264,10 @@ main (int argc, char** argv) if (!rundir) rundir = "/run"; - chdir(rundir); + if (chdir(rundir)) { + perror("chdir"); + exit(-1); + } if (mkfifo(PSPLASH_FIFO, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP)) { From patchwork Mon Apr 25 07:59:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasyl Vavrychuk X-Patchwork-Id: 7089 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8396EC54F3D for ; Mon, 25 Apr 2022 19:26:13 +0000 (UTC) Received: from repost01.tmes.trendmicro.eu (repost01.tmes.trendmicro.eu [18.185.115.10]) by mx.groups.io with SMTP id smtpd.web09.26987.1650873633734621449 for ; Mon, 25 Apr 2022 01:00:34 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@opensynergy.com header.s=tm-dkim-20210503141657 header.b=dEVHn50g; spf=pass (domain: opensynergy.com, ip: 18.185.115.10, mailfrom: vasyl.vavrychuk@opensynergy.com) Received: from 104.47.8.58_.trendmicro.com (unknown [172.21.163.172]) by repost01.tmes.trendmicro.eu (Postfix) with SMTP id 586F31000174A for ; Mon, 25 Apr 2022 08:00:32 +0000 (UTC) X-TM-MAIL-RECEIVED-TIME: 1650873629.257000 X-TM-MAIL-UUID: 61c7539f-e657-4999-8eb3-28c3bd3cf4b4 Received: from EUR03-AM5-obe.outbound.protection.outlook.com (unknown [104.47.8.58]) by repre01.tmes.trendmicro.eu (Trend Micro Email Security) with ESMTPS id 3EEE51000177D for ; Mon, 25 Apr 2022 08:00:29 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M5d9Pm/Iji9MfX9Bfw3dIA5rHTpNB/M/gmu3bp4rq+vNDRTjSSqK9pAumDyAH/R/KErcaJr6I1pWU4XMhIRyvhGEA6iJPlOD4yFKNsqJW9kRt6ez8H2OgO18/Cnm2Fot1QqdQOCKTlAaS1d6A/gKHEWjjyRYGqa1KZXBINEbbpTssKAAqoBI9kiYWoGq4JVCjB6aeeCxvrQBLHrSNdnsLGRV+9AQgmC+kvvAHeBLYWcin3suWIfXEXbBdcyzNEj3Wg1xQoDPwNBIlQuuBBt3WdGuOgtVpdvFa6qLEybIBIsGwzw4wmRE8fT+J50Diix3NWM/qSS1cAyWMquHd+BRUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ycof7EBR/+z1AquB4ea+ug9gfhupVVwjlJ5ec5I61EI=; b=JC6iNYCPGrVvAXxjNT84ysOkfyhs1X/6dom4jKbMNzBvg6Gwhm1p1KBhCCEex1CZOf2FreUMKrukZG8q9zZbiflRdJ+9vqdJfMiP8yKnzQTNCeiZbKAR+aG7S0MCvzpABnUIWXP+oskU3U2BiWb4tq91ZrLuPxqFea0TSJaxzpKEm423XwD41wEZdynp3YjZa1G5zNt1uQy7lD1wXajAvgq8yhZ3Be7MEIhhxZuUfPrNreDs64xz0tFxP3jmOC9+oPgAuR83ziTYcIw8dyBlynmOTW7ruO0IgpR5A+T/qiIr+Qfbq1nDIFmAo+fAzuD8/Tz489AxPX5n58Ru4Bt4Rw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 217.66.60.4) smtp.rcpttodomain=lists.yoctoproject.org smtp.mailfrom=opensynergy.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=opensynergy.com; dkim=none (message not signed); arc=none X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 217.66.60.4) smtp.mailfrom=opensynergy.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=opensynergy.com; Received-SPF: Pass (protection.outlook.com: domain of opensynergy.com designates 217.66.60.4 as permitted sender) receiver=protection.outlook.com; client-ip=217.66.60.4; helo=SR-MAIL-03.open-synergy.com; From: Vasyl Vavrychuk To: yocto@lists.yoctoproject.org Cc: Vasyl Vavrychuk Subject: [psplash][RFC PATCH 03/14] Remove unused save_termios Date: Mon, 25 Apr 2022 10:59:43 +0300 Message-Id: <20220425075954.10427-4-vasyl.vavrychuk@opensynergy.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220425075954.10427-1-vasyl.vavrychuk@opensynergy.com> References: <20220425075954.10427-1-vasyl.vavrychuk@opensynergy.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3d683571-317c-4919-a427-08da2691a4a5 X-MS-TrafficTypeDiagnostic: VI1PR04MB4462:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: f7eFJtMrHCJf3i5IWBVJ03f/0yTPQjFY7yD5RuR93u5NWiMVf8Lb5qwHbgnNdmKqc8pXN7X1lubmm/rCkg9W0dsW5AwZF9yJCDxqgMFXsILoE6s5a356hs/4euZ4d9VaZPp3RGxvYTphvSKFp6ioLIbYk3p5q6mhv8Ykg9bY7MwKliaEMaEfjhMHrfzXCnBfDslGsSszimNpaS1pENa1lem1tqAo0zzJBDwtWHnA/daRVomjFCBhpT72EXBpql+dEln01auvUas8aYKwLZKPcr+cOPPS74jVSWWw9hnq2StvELykoiHxnPDRv4dUjEF6BhCQaNab6mTQ0AYZBb0KSgV4SjDpYFE4/w4piSkXy8Tjj1TPljsnxLxRw4ydTOrnyOYMYnM35KKhUH00oOrAv3XNcQKQLFlPybm6wHz8jua8HFxJdkDdLao7m9lfcX7LNtWASjWPin5OvRXXKxDHqJR+6XQXLRYmVe8F5MfTG2NzYnD3rOA4YYqVGtHQuz2aJ4vPXfjYGQKzeZ5th4qyuBQBYMw5ctKP+wj2f9LVJXrY9kU2eae+tf/0bL3c2jRQpkjlsoOhg8jUIkx9+5f8CKCD/nM2VCS68DE2KgfsmITW3FGh43Hue1p+kQnu8+9WR1cayHHYAhsijlWEM9DWsrgLugwnboeSvihTyEm33W2mJhB4xjXCLtaQYhHjdAnP X-Forefront-Antispam-Report: CIP:217.66.60.4;CTRY:DE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SR-MAIL-03.open-synergy.com;PTR:mx1.opensynergy.com;CAT:NONE;SFS:(13230001)(346002)(136003)(396003)(376002)(39830400003)(46966006)(36840700001)(2616005)(1076003)(336012)(186003)(47076005)(107886003)(316002)(83380400001)(6916009)(36756003)(36860700001)(40480700001)(82310400005)(26005)(4744005)(8676002)(42186006)(44832011)(4326008)(8936002)(70206006)(5660300002)(2906002)(508600001)(81166007)(86362001)(70586007);DIR:OUT;SFP:1102; X-OriginatorOrg: opensynergy.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2022 08:00:19.9841 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3d683571-317c-4919-a427-08da2691a4a5 X-MS-Exchange-CrossTenant-Id: 800fae25-9b1b-4edc-993d-c939c4e84a64 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=800fae25-9b1b-4edc-993d-c939c4e84a64;Ip=[217.66.60.4];Helo=[SR-MAIL-03.open-synergy.com] X-MS-Exchange-CrossTenant-AuthSource: VI1EUR05FT014.eop-eur05.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4462 X-TM-AS-ERS: 104.47.8.58-0.0.0.0 X-TMASE-Version: StarCloud-1.3-8.8.1001-26854.006 X-TMASE-Result: 10-2.255300-4.000000 X-TMASE-MatchedRID: /m0W4FzTGdeRmYpU4vHLUk7nLUqYrlslFIuBIWrdOeM3ZbGC9oP/O6F3 5mbpOvU8ED0QTbY0JODsk41hdN/PKpcFdomgH0lnURmnjiU5zFtpkajQR5gb3savT21DsLD/UEh Wy9W70AF5zdAzex5xZt2tR2Hfn51B2Y6fIpeGZvbgyreTUiPnmXQbxWoQMLmFt0FJ2BAmfQuUTG VAhB5EbQ== X-TMASE-XGENCLOUD: 41f04398-f231-434b-aac5-e8e21035d8ed-0-0-200-0 X-TM-Deliver-Signature: 724FF21076E2C934105B099A73452F13 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=opensynergy.com; s=TM-DKIM-20210503141657; t=1650873632; bh=m6Ucj+zDOYnd6OesjliSsJfIWPCCXISDQ2SeuJmW2M8=; l=769; h=From:To:Date; b=dEVHn50gZS8co78J+rHP9KMuIZzYL5cY9M7icnA3kOO4a3abcD5JMqApaLN85y2DI NdxNGO5fYjm5jYDGO87cEa2kZMtkODuEwA1E+giZWvV4y3tZ9WmSEMUosN0XMxqbTu jg0JvTrixNwYOk/PJeFCL0NJ+5gu7lnV+gWxlF9PI4SCwnDEH5DbxQNVbchRIZtxy8 yhaj4jNgqq29OXa4B+g1EyQwdHpAKaTer5aoNdUItIJISuWp+rZk9SbWzXZYyMFCey 6PV/ZhpGWctg7cktDCOJPscANMrTkh8XupUaITbVMXEEwbFK2Jr0E4fH3g3fcMKv5z ShXNs6zdrXY0g== List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 25 Apr 2022 19:26:13 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto/message/56869 Signed-off-by: Vasyl Vavrychuk --- psplash-fb.h | 1 - psplash.h | 1 - 2 files changed, 2 deletions(-) diff --git a/psplash-fb.h b/psplash-fb.h index eafa293..6c4599c 100644 --- a/psplash-fb.h +++ b/psplash-fb.h @@ -22,7 +22,6 @@ typedef struct PSplashFB { int fd; struct fb_var_screeninfo fb_var; - struct termios save_termios; int type; int visual; int width, height; diff --git a/psplash.h b/psplash.h index 3739ca3..8e68b7b 100644 --- a/psplash.h +++ b/psplash.h @@ -32,7 +32,6 @@ #include #include #include -#include #include typedef uint8_t uint8; From patchwork Mon Apr 25 07:59:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasyl Vavrychuk X-Patchwork-Id: 7088 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7507BC54F3B for ; Mon, 25 Apr 2022 19:26:13 +0000 (UTC) Received: from repost01.tmes.trendmicro.eu (repost01.tmes.trendmicro.eu [18.185.115.30]) by mx.groups.io with SMTP id smtpd.web10.26692.1650873630938861794 for ; Mon, 25 Apr 2022 01:00:31 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@opensynergy.com header.s=tm-dkim-20210503141657 header.b=R0tDgxis; spf=pass (domain: opensynergy.com, ip: 18.185.115.30, mailfrom: vasyl.vavrychuk@opensynergy.com) Received: from 104.47.1.57_.trendmicro.com (unknown [172.21.180.2]) by repost01.tmes.trendmicro.eu (Postfix) with SMTP id 79E2D10000BAE for ; Mon, 25 Apr 2022 08:00:29 +0000 (UTC) X-TM-MAIL-RECEIVED-TIME: 1650873628.250000 X-TM-MAIL-UUID: e179b477-f3e5-4f7c-8249-3c01809e7a2d Received: from EUR01-VE1-obe.outbound.protection.outlook.com (unknown [104.47.1.57]) by repre01.tmes.trendmicro.eu (Trend Micro Email Security) with ESMTPS id 3D56A10000317 for ; Mon, 25 Apr 2022 08:00:28 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L3rKcvxuspWi4CR8Gc0fSwbGuSA4VShCsBhJfcYnAe4tq+3SsdrlBqyHTXb84Y7cElEEtccsN/Y8nCy36E5z38xGw4Bx5JgEslMHuRmud6ttnouD9dZyI/Cpmc8GUqdrGp0fJE2X5ttwWhgJHtMi6ImbOk0u3ddb1+vGSdM0WRFNjIhMCfWM22Y+r2kA9efAUVfodAqN6IOf88iy5M/J1x4huB4tMhKccT58aVa6yq9MghmVFa/wfDpVbGk6+OcVlw78kfqE7748ZM0OfWrfNtvM9jhzILs8mJz3rVdzb7ppX02NX0Qe1nCJcjEfrE4rYw0kid2IbWp6ZiRJ2Cb0LQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=u4GBG48HkmSF+5dl6xvn+e6HaeaNVALI+X28kd6+irA=; b=h17CJ/Q065kfAj1ir/nVDSdrHOIIXlxCGJwO80a54PhihgwfOURsn8YLNglvnOA+jgXtHjBJCom5kkeCC4OiZX5A40udaBiipK/yfbNWq1JWhhFnn5ChuRqIOMGmqiHnqcfxTBbykxpw1aEVtWCBSNAO4gQWlrC0PdiuQc1wcHIYsrOdag0amPuu1sdKF1FlCbRsIE6PPZJRsXKZyczrTQCNP/E4LvWwYmYIEDBajT4GLT1V1klHFAfyT6JisVjJBLzpgd7UUZRAyiFezU2iLWixrH/cm/R+2RSIbJFI9xu12e15BpSCzNFgB0VOe0o4vR0BmYBHJn1WkFL7TYpejw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 217.66.60.4) smtp.rcpttodomain=lists.yoctoproject.org smtp.mailfrom=opensynergy.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=opensynergy.com; dkim=none (message not signed); arc=none X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 217.66.60.4) smtp.mailfrom=opensynergy.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=opensynergy.com; Received-SPF: Pass (protection.outlook.com: domain of opensynergy.com designates 217.66.60.4 as permitted sender) receiver=protection.outlook.com; client-ip=217.66.60.4; helo=SR-MAIL-03.open-synergy.com; From: Vasyl Vavrychuk To: yocto@lists.yoctoproject.org Cc: Vasyl Vavrychuk Subject: [psplash][RFC PATCH 04/14] Remove 'psplash-fb.h' from 'psplash.h' Date: Mon, 25 Apr 2022 10:59:44 +0300 Message-Id: <20220425075954.10427-5-vasyl.vavrychuk@opensynergy.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220425075954.10427-1-vasyl.vavrychuk@opensynergy.com> References: <20220425075954.10427-1-vasyl.vavrychuk@opensynergy.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 291b4fc3-f83c-4457-23f6-08da2691a4c0 X-MS-TrafficTypeDiagnostic: AM5PR0402MB2771:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XNXS6rnMwiEcrAOXJ5htvAJS5WDBVP5dIRjRaWZ6NuXL2bgUdzLBtHNOC9UEefLA0AgY/q4kKiacmlayzpjcF5a+XygL164l9yXJk0WK6OtNA969p2x7nohnOKmQXrOGejgoswbAVLXRfopJtMy9ov46sb5eDmKWuTVDg/jiOSblZefimSfHS/XLD/KRPqiNHHHYY5m3kbo1Bz5nmmck2WPoJ86mv3e82CqD27IVT2LpsUwMCPeB94DklFW9NWTsbKQveu3MfYth41PYMPSm+9uVHN/682Cbm6KsidHoY+CQCnJ3jXOwUOKSrr+0HS3D3krtp/0hP5Rd/Uutz2y32/8XfEn74hXsFfQFwJZF8BcG3hRK3vS+BqAGGLl/cizQjzuntWmqx1nRfVCaq25/p6PLAlWS8bwO/8Rv9qnLplbUvwH/zg8tTRhZc4N9YF3w3WidAZKcwUDdmNKwd1SSaneDzzPuEI+5uSde4L8VxP1qvGrnnR37moQGTnE9SB4nmShZxhrNJYbgnFc1k7Yl1I0cuHczZPuVJwVCi0x0StTM0WNA0atVBcmkFCDjVE0tTpLe19qzpdzwg/7FaWz9Dwd6K93v9NXs1nBRFZWWf3YJkWzSUpePbYVsdQs+dusNrtpapnuPGsWLqVgg/B/WgvA0YrU/PY0MD9uoaPtIGaaV8EF3qtirvYRMq+6X0q+Q X-Forefront-Antispam-Report: CIP:217.66.60.4;CTRY:DE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SR-MAIL-03.open-synergy.com;PTR:mx1.opensynergy.com;CAT:NONE;SFS:(13230001)(376002)(39830400003)(136003)(346002)(396003)(36840700001)(46966006)(36756003)(70206006)(508600001)(107886003)(2906002)(70586007)(4326008)(44832011)(8936002)(6916009)(26005)(82310400005)(5660300002)(42186006)(316002)(86362001)(81166007)(2616005)(1076003)(47076005)(36860700001)(40480700001)(8676002)(83380400001)(336012)(186003);DIR:OUT;SFP:1102; X-OriginatorOrg: opensynergy.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2022 08:00:20.1734 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 291b4fc3-f83c-4457-23f6-08da2691a4c0 X-MS-Exchange-CrossTenant-Id: 800fae25-9b1b-4edc-993d-c939c4e84a64 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=800fae25-9b1b-4edc-993d-c939c4e84a64;Ip=[217.66.60.4];Helo=[SR-MAIL-03.open-synergy.com] X-MS-Exchange-CrossTenant-AuthSource: AM6EUR05FT013.eop-eur05.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0402MB2771 X-TM-AS-ERS: 104.47.1.57-0.0.0.0 X-TMASE-Version: StarCloud-1.3-8.8.1001-26854.006 X-TMASE-Result: 10-1.484300-4.000000 X-TMASE-MatchedRID: Se4t54mhS/3qTm7+Zl/pFbnHu4BcYSmtwTlc9CcHMZerwqxtE531VNnf JrUSEbFDXht2JKuRTne5cURAloITPv46FBYGUp+VFEUknJ/kEl5lVdRvgpNpe/oLR4+zsDTtlu/ VKvCjKPVrRX3THGQ0DwfoPL/vEdSKauYV82NEiviQZicWxHZLvlqAtPM/2FFilExlQIQeRG0= X-TMASE-XGENCLOUD: b5846e52-dafe-4512-a4b4-27dd7ffd23cd-0-0-200-0 X-TM-Deliver-Signature: D8B6597D06D000C8C5D42E9024F27875 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=opensynergy.com; s=TM-DKIM-20210503141657; t=1650873629; bh=Rj4En4melWC2YiIt5RpJmKsHjSFikXPZGK9BB7XnQJ0=; l=1553; h=From:To:Date; b=R0tDgxisIJYC+Z+0d9U9/LJPfL1S9gE6NXTKS0upfF5T5gHA2T8uw3vjWpELKCG0I cYIYb0FmGnl2WE3trbUNSYTSs+Bzl5dbniRKE4pK4u7t24aQ6XWtxMqEXKNKu7+UXA EF3C+TTuDgUsnPYHsg/UUVjjxDKqjVImhX7L1tcFA5XtqYZsSHR1aHVzGQGlG0DkR0 uiLKRm5W11er6KtSBBtGyqLK7Ty02d7S8EzdUchGOhfgGycjhWImYbyGRxLMohGSeK YV535ylc0hAAKYlhuXgz9zseE/dJu4TueEdeEja8zHFf8tK3mCmoZ2IagmqrGEEs2T uCZGtcvgHIIIg== List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 25 Apr 2022 19:26:13 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto/message/56867 psplash might not be necessary based on framebuffer, it could use DRM in future too. Signed-off-by: Vasyl Vavrychuk --- psplash-fb.c | 2 +- psplash-fb.h | 3 +++ psplash.c | 1 + psplash.h | 2 -- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/psplash-fb.c b/psplash-fb.c index 1d2d7db..5dea82a 100644 --- a/psplash-fb.c +++ b/psplash-fb.c @@ -8,7 +8,7 @@ */ #include -#include "psplash.h" +#include "psplash-fb.h" static void psplash_wait_for_vsync(PSplashFB *fb) diff --git a/psplash-fb.h b/psplash-fb.h index 6c4599c..4d5c460 100644 --- a/psplash-fb.h +++ b/psplash-fb.h @@ -10,6 +10,9 @@ #ifndef _HAVE_PSPLASH_FB_H #define _HAVE_PSPLASH_FB_H +#include +#include "psplash.h" + enum RGBMode { RGB565, BGR565, diff --git a/psplash.c b/psplash.c index 62244ba..18c012b 100644 --- a/psplash.c +++ b/psplash.c @@ -11,6 +11,7 @@ */ #include "psplash.h" +#include "psplash-fb.h" #include "psplash-config.h" #include "psplash-colors.h" #include "psplash-poky-img.h" diff --git a/psplash.h b/psplash.h index 8e68b7b..7489e75 100644 --- a/psplash.h +++ b/psplash.h @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -78,7 +77,6 @@ typedef struct PSplashFont PSplashFont; -#include "psplash-fb.h" #include "psplash-console.h" #endif From patchwork Mon Apr 25 07:59:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasyl Vavrychuk X-Patchwork-Id: 7085 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52004C49EA2 for ; Mon, 25 Apr 2022 19:26:13 +0000 (UTC) Received: from repost01.tmes.trendmicro.eu (repost01.tmes.trendmicro.eu [18.185.115.4]) by mx.groups.io with SMTP id smtpd.web10.26690.1650873625220909175 for ; Mon, 25 Apr 2022 01:00:26 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@opensynergy.com header.s=tm-dkim-20210503141657 header.b=fOKs8YS+; spf=pass (domain: opensynergy.com, ip: 18.185.115.4, mailfrom: vasyl.vavrychuk@opensynergy.com) Received: from 104.47.8.57_.trendmicro.com (unknown [172.21.194.146]) by repost01.tmes.trendmicro.eu (Postfix) with SMTP id 345C7100022EA for ; Mon, 25 Apr 2022 08:00:23 +0000 (UTC) X-TM-MAIL-RECEIVED-TIME: 1650873622.552000 X-TM-MAIL-UUID: 63ddfc28-a6f2-436a-af6f-9e2115adb232 Received: from EUR03-AM5-obe.outbound.protection.outlook.com (unknown [104.47.8.57]) by repre01.tmes.trendmicro.eu (Trend Micro Email Security) with ESMTPS id 86DF110002929 for ; Mon, 25 Apr 2022 08:00:22 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gD7Ln5+6akcAIf4cN61i7HALt58GIrLCXe1CYyX4AOjCl1Vh5kkHMloRQk1kdMVzCIjz5gYgb3Qi0xYhjJfPSqzZ5aMAwa4v+pMWJ2Bg2W/h9hjYHUiOOrIORi72J/guhHpgaKHjtXE1Z4hczxFeP2syH5kPWiZpY9nuIYCLDZpoCDiqOD32+QI6ja1Zc7rsgw0Gb4J9HOXyV7YJcuev6RqXXKZQFwMKqaCD0uGPB6m7Q77lFo8SHPMVTS2a5YsKl2/T69Acl6dY8pp/UO9jxYlr0FQhyeQ8m5o0x64n27XhOKEccnaEOUcWZQxwx9YLSClH/pRTy+tj3Cm//yOebQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jzBBXgUvJ+7FEum6vlWtj0STIWorwKLq4yMwrDlbZac=; b=eS3ronOWOwLVqLhsoepiWOh9FfITxSm0nu816V8ooUL9+veN/5NTlUov1EXfKSHCSZYw42BObC3aMidcqm21igJ/SBy/C3ZbSSHY2WjXnYteuoRL8xP3VcPRmgR7Z6qktTWZN6hMAAateRjmfKasJKtV638ar0aN/x/LPEJ8s8+9WxyVh19jdy7Zcqc6aPNGypTkRjhCAsv6pSAJP9bafk25yJHGSVf6mqLOr8/E7RatULyePU2og2hW1O/rck37irmDTfZnL13pEIPZydCmbxEPjzNWhP8RNgz6nUwfv1ODcpWnKIQyugAsncvlK1mOnxmb/V41w2yd3NWIr+mtqw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 217.66.60.4) smtp.rcpttodomain=lists.yoctoproject.org smtp.mailfrom=opensynergy.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=opensynergy.com; dkim=none (message not signed); arc=none X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 217.66.60.4) smtp.mailfrom=opensynergy.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=opensynergy.com; Received-SPF: Pass (protection.outlook.com: domain of opensynergy.com designates 217.66.60.4 as permitted sender) receiver=protection.outlook.com; client-ip=217.66.60.4; helo=SR-MAIL-03.open-synergy.com; From: Vasyl Vavrychuk To: yocto@lists.yoctoproject.org Cc: Vasyl Vavrychuk Subject: [psplash][RFC PATCH 05/14] Extract plot pixel from psplash-fb Date: Mon, 25 Apr 2022 10:59:45 +0300 Message-Id: <20220425075954.10427-6-vasyl.vavrychuk@opensynergy.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220425075954.10427-1-vasyl.vavrychuk@opensynergy.com> References: <20220425075954.10427-1-vasyl.vavrychuk@opensynergy.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 78c64070-12b5-4136-4b42-08da2691a4ff X-MS-TrafficTypeDiagnostic: AM0PR04MB5602:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jsR1DPd4cE20cwwtE6W8/RtBqCBXtc30Mz9Ml0Mj2md8qnSbnwYRJp3i9VRszxvj2KSdzJmlMWIC7Pwt/X81jyLSp4FdvMVzcKJM+eLdOWg93WE5M7lt20oe7r8kMgXcyKI3dei0jut8Ar2zhZ9xyVGosYQD34oSoXjkWX+6mI4Ilfjnm3+ifyKzsDJ/JxtUON7xHZ4Jxy1zWxg+Hs+cxoCaIrEsMwECahZ1ZVzwLpGQap8eqiKhuWmYHqL8CQY898HrVQnm7HNoPAb7G4OG2PsiOTG5DBrZJorYuRmlTTpEThBlmM/50Vie/7agzXZFtjG43blYaUlnQAa6w3AY5AAJQnxZbWgvUHy9WeSRO7RrH4Bw6u7H63yFWjw5+LvBmEPumFH3XSTyUubSwIprZkYtd/pYqZHyDS8zU/TG9lv+jgXGMqNxUfrfFjPLaZ3ryfh+Fblq5PcobsQlU4o7Dl4rdX8yZwufxtFPv9FMm58bvW8TlLLRzw4ykp0GtgnbSczcpAzp5DjO/2nd0cc3a3y1i1CvDCvNF5zjpvXDoMprRNl55VpTOdJTGOsJR/mnkXfck0ZUoQyTNM1x2mbqtscra+nbfMddfZueOSDREkx51AZMmwnzeoYdp0xSkRwSEjOotTQ4ZswsCBhxg4QcB1KfhxofgOTKSKdM9eViwiYeflVFkkEheR0hALQ8f6iz X-Forefront-Antispam-Report: CIP:217.66.60.4;CTRY:DE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SR-MAIL-03.open-synergy.com;PTR:mx1.opensynergy.com;CAT:NONE;SFS:(13230001)(346002)(376002)(136003)(396003)(39830400003)(36840700001)(46966006)(4326008)(86362001)(2616005)(8676002)(81166007)(30864003)(44832011)(26005)(2906002)(83380400001)(36860700001)(5660300002)(1076003)(508600001)(8936002)(42186006)(82310400005)(36756003)(316002)(186003)(40480700001)(70206006)(336012)(70586007)(107886003)(6916009)(47076005);DIR:OUT;SFP:1102; X-OriginatorOrg: opensynergy.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2022 08:00:20.5873 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 78c64070-12b5-4136-4b42-08da2691a4ff X-MS-Exchange-CrossTenant-Id: 800fae25-9b1b-4edc-993d-c939c4e84a64 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=800fae25-9b1b-4edc-993d-c939c4e84a64;Ip=[217.66.60.4];Helo=[SR-MAIL-03.open-synergy.com] X-MS-Exchange-CrossTenant-AuthSource: VI1EUR05FT009.eop-eur05.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB5602 X-TM-AS-ERS: 104.47.8.57-0.0.0.0 X-TMASE-Version: StarCloud-1.3-8.8.1001-26854.006 X-TMASE-Result: 10--6.057900-4.000000 X-TMASE-MatchedRID: mU/J5maPYndaPCzml0uYFk7nLUqYrlslFIuBIWrdOePfUZT83lbkELNA b6BbLCYFIJ0D3Hhbi4Qef9c7rUhRihNSYeRE3U64CtzGvPCy/m5SuvtBzlaEqFH3rkvzbWPMlYu iBD2rlTc5bYnA9LjsLWs8jfVB5CrplFKRvEp4lzjknMSTG9lH+M/I/m8aIlgMmS0TtehjpJJzWe vD8c5nkctIYRBUGpVAR9K0Q1TPp1Q23LDAh/mSxV07myvEBAIZiK5qg1cmsr/+Aw16GgqpO3w6H 06bMgivNPgy0T0qydVUdifX/ssRD/PxwD+/KEW2lXePXNM4FjMzNsXWBvGVBk+Ce+Qfci980beU y1EUccni8zVgXoAltpWD5DDAqPadSwOSQ/fMiOrdB/CxWTRRu4as+d5/8j56eLMHTOI5Rs5IHvj YONNJpl/Y+4pjRdG3L39Xd682RqFW4YAcfB4u2w== X-TMASE-XGENCLOUD: e93a92f6-ac35-92f1-9423-da4e12e37e20-0-0-200-0 X-TM-Deliver-Signature: 240188846702982F51367A32375DEAE8 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=opensynergy.com; s=TM-DKIM-20210503141657; t=1650873623; bh=K5nWcnlak1nWnIs0TnWhAyYBKhDeyu/XjLAiyyZ0k6k=; l=19274; h=From:To:Date; b=fOKs8YS+32bHlRE42a30ekHRXLIkST3r/8hM5u0QpZMuMEUEKBu7GJ1uuoU67XXCr stH759c5ybQzzsCMj8/EOrss+W6KZgyVN3ObmwgGV5VNRSVGzdrA4Y8ANKigQnEtE/ OepVeVvIm2Hi64eLxSaXRi2RyC+z3vDekC6IojfgU4EzE7mIqow1cOfwnh92a4LaHu xdTw669ez2i2LnIHgFuHq6fyWYAl6UFL6BNUNxpI4aOn8KKSzbE/LdtlZYWkWM0Crs wzQK41aMI08Np65TENTPtyrnaMkDvCuIVa3tf/p6h88FPckH64V3Y4I8Hp/Kho3Ahc eRg5utF1vlzQg== List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 25 Apr 2022 19:26:13 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto/message/56861 psplash_fb_plot_pixel is in fact framebuffer independent. Signed-off-by: Vasyl Vavrychuk --- Makefile.am | 3 +- psplash-draw.c | 120 +++++++++++++++++++++++++++++++ psplash-draw.h | 51 +++++++++++++ psplash-fb.c | 191 +++++++++++-------------------------------------- psplash-fb.h | 25 ++----- psplash.c | 20 +++--- 6 files changed, 229 insertions(+), 181 deletions(-) create mode 100644 psplash-draw.c create mode 100644 psplash-draw.h diff --git a/Makefile.am b/Makefile.am index 310e126..375b926 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,7 +5,8 @@ AM_CFLAGS = $(GCC_FLAGS) $(EXTRA_GCC_FLAGS) -D_GNU_SOURCE -DFONT_HEADER=\"$(FONT psplash_SOURCES = psplash.c psplash.h psplash-fb.c psplash-fb.h \ psplash-console.c psplash-console.h \ psplash-colors.h psplash-config.h \ - psplash-poky-img.h psplash-bar-img.h $(FONT_NAME)-font.h + psplash-poky-img.h psplash-bar-img.h $(FONT_NAME)-font.h \ + psplash-draw.c psplash-draw.h BUILT_SOURCES = psplash-poky-img.h psplash-bar-img.h psplash_write_SOURCES = psplash-write.c psplash.h diff --git a/psplash-draw.c b/psplash-draw.c new file mode 100644 index 0000000..570cfce --- /dev/null +++ b/psplash-draw.c @@ -0,0 +1,120 @@ +/* + * pslash - a lightweight framebuffer splashscreen for embedded devices. + * + * Copyright (c) 2006 Matthew Allum + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + */ + +#include "psplash-draw.h" + +#define OFFSET(canvas, x, y) (((y) * (canvas)->stride) + ((x) * ((canvas)->bpp >> 3))) + +/* TODO: change to 'static inline' as psplash_fb_plot_pixel was before */ +void +psplash_plot_pixel(PSplashCanvas *canvas, + int x, + int y, + uint8 red, + uint8 green, + uint8 blue) +{ + /* Always write to back data (data) which points to the right data with or + * without double buffering support */ + int off; + + if (x < 0 || x > canvas->width-1 || y < 0 || y > canvas->height-1) + return; + + switch (canvas->angle) + { + case 270: + off = OFFSET (canvas, canvas->height - y - 1, x); + break; + case 180: + off = OFFSET (canvas, canvas->width - x - 1, canvas->height - y - 1); + break; + case 90: + off = OFFSET (canvas, y, canvas->width - x - 1); + break; + case 0: + default: + off = OFFSET (canvas, x, y); + break; + } + + if (canvas->rgbmode == RGB565 || canvas->rgbmode == RGB888) { + switch (canvas->bpp) + { + case 24: +#if __BYTE_ORDER == __BIG_ENDIAN + *(canvas->data + off + 0) = red; + *(canvas->data + off + 1) = green; + *(canvas->data + off + 2) = blue; +#else + *(canvas->data + off + 0) = blue; + *(canvas->data + off + 1) = green; + *(canvas->data + off + 2) = red; +#endif + break; + case 32: + *(volatile uint32_t *) (canvas->data + off) + = (red << 16) | (green << 8) | (blue); + break; + + case 16: + *(volatile uint16_t *) (canvas->data + off) + = ((red >> 3) << 11) | ((green >> 2) << 5) | (blue >> 3); + break; + default: + /* depth not supported yet */ + break; + } + } else if (canvas->rgbmode == BGR565 || canvas->rgbmode == BGR888) { + switch (canvas->bpp) + { + case 24: +#if __BYTE_ORDER == __BIG_ENDIAN + *(canvas->data + off + 0) = blue; + *(canvas->data + off + 1) = green; + *(canvas->data + off + 2) = red; +#else + *(canvas->data + off + 0) = red; + *(canvas->data + off + 1) = green; + *(canvas->data + off + 2) = blue; +#endif + break; + case 32: + *(volatile uint32_t *) (canvas->data + off) + = (blue << 16) | (green << 8) | (red); + break; + case 16: + *(volatile uint16_t *) (canvas->data + off) + = ((blue >> 3) << 11) | ((green >> 2) << 5) | (red >> 3); + break; + default: + /* depth not supported yet */ + break; + } + } else { + switch (canvas->bpp) + { + case 32: + *(volatile uint32_t *) (canvas->data + off) + = ((red >> (8 - canvas->red_length)) << canvas->red_offset) + | ((green >> (8 - canvas->green_length)) << canvas->green_offset) + | ((blue >> (8 - canvas->blue_length)) << canvas->blue_offset); + break; + case 16: + *(volatile uint16_t *) (canvas->data + off) + = ((red >> (8 - canvas->red_length)) << canvas->red_offset) + | ((green >> (8 - canvas->green_length)) << canvas->green_offset) + | ((blue >> (8 - canvas->blue_length)) << canvas->blue_offset); + break; + default: + /* depth not supported yet */ + break; + } + } +} diff --git a/psplash-draw.h b/psplash-draw.h new file mode 100644 index 0000000..ab2d4d2 --- /dev/null +++ b/psplash-draw.h @@ -0,0 +1,51 @@ +/* + * pslash - a lightweight framebuffer splashscreen for embedded devices. + * + * Copyright (c) 2006 Matthew Allum + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + */ + +#ifndef _HAVE_PSPLASH_CANVAS_H +#define _HAVE_PSPLASH_CANVAS_H + +#include "psplash.h" + +enum RGBMode { + RGB565, + BGR565, + RGB888, + BGR888, + GENERIC, +}; + +typedef struct PSplashCanvas +{ + int width, height; + int bpp; + int stride; + char *data; + + int angle; + + enum RGBMode rgbmode; + int red_offset; + int red_length; + int green_offset; + int green_length; + int blue_offset; + int blue_length; +} +PSplashCanvas; + +/* TODO: Remove after rest of drawing functions migrated to psplash-draw.c */ +void +psplash_plot_pixel(PSplashCanvas *canvas, + int x, + int y, + uint8 red, + uint8 green, + uint8 blue); + +#endif diff --git a/psplash-fb.c b/psplash-fb.c index 5dea82a..a7029c5 100644 --- a/psplash-fb.c +++ b/psplash-fb.c @@ -42,10 +42,11 @@ psplash_fb_flip(PSplashFB *fb, int sync) tmp = fb->fdata; fb->fdata = fb->bdata; fb->bdata = tmp; + fb->canvas.data = fb->bdata; /* Sync new front to new back when requested */ if (sync) { - memcpy(fb->bdata, fb->fdata, fb->stride * fb->real_height); + memcpy(fb->bdata, fb->fdata, fb->canvas.stride * fb->real_height); } } } @@ -220,42 +221,42 @@ psplash_fb_new (int angle, int fbdev_id) } } - fb->real_width = fb->width = fb_var.xres; - fb->real_height = fb->height = fb_var.yres; - fb->bpp = fb_var.bits_per_pixel; - fb->stride = fb_fix.line_length; + fb->real_width = fb->canvas.width = fb_var.xres; + fb->real_height = fb->canvas.height = fb_var.yres; + fb->canvas.bpp = fb_var.bits_per_pixel; + fb->canvas.stride = fb_fix.line_length; fb->type = fb_fix.type; fb->visual = fb_fix.visual; - fb->red_offset = fb_var.red.offset; - fb->red_length = fb_var.red.length; - fb->green_offset = fb_var.green.offset; - fb->green_length = fb_var.green.length; - fb->blue_offset = fb_var.blue.offset; - fb->blue_length = fb_var.blue.length; - - if (fb->red_offset == 11 && fb->red_length == 5 && - fb->green_offset == 5 && fb->green_length == 6 && - fb->blue_offset == 0 && fb->blue_length == 5) { - fb->rgbmode = RGB565; - } else if (fb->red_offset == 0 && fb->red_length == 5 && - fb->green_offset == 5 && fb->green_length == 6 && - fb->blue_offset == 11 && fb->blue_length == 5) { - fb->rgbmode = BGR565; - } else if (fb->red_offset == 16 && fb->red_length == 8 && - fb->green_offset == 8 && fb->green_length == 8 && - fb->blue_offset == 0 && fb->blue_length == 8) { - fb->rgbmode = RGB888; - } else if (fb->red_offset == 0 && fb->red_length == 8 && - fb->green_offset == 8 && fb->green_length == 8 && - fb->blue_offset == 16 && fb->blue_length == 8) { - fb->rgbmode = BGR888; + fb->canvas.red_offset = fb_var.red.offset; + fb->canvas.red_length = fb_var.red.length; + fb->canvas.green_offset = fb_var.green.offset; + fb->canvas.green_length = fb_var.green.length; + fb->canvas.blue_offset = fb_var.blue.offset; + fb->canvas.blue_length = fb_var.blue.length; + + if (fb->canvas.red_offset == 11 && fb->canvas.red_length == 5 && + fb->canvas.green_offset == 5 && fb->canvas.green_length == 6 && + fb->canvas.blue_offset == 0 && fb->canvas.blue_length == 5) { + fb->canvas.rgbmode = RGB565; + } else if (fb->canvas.red_offset == 0 && fb->canvas.red_length == 5 && + fb->canvas.green_offset == 5 && fb->canvas.green_length == 6 && + fb->canvas.blue_offset == 11 && fb->canvas.blue_length == 5) { + fb->canvas.rgbmode = BGR565; + } else if (fb->canvas.red_offset == 16 && fb->canvas.red_length == 8 && + fb->canvas.green_offset == 8 && fb->canvas.green_length == 8 && + fb->canvas.blue_offset == 0 && fb->canvas.blue_length == 8) { + fb->canvas.rgbmode = RGB888; + } else if (fb->canvas.red_offset == 0 && fb->canvas.red_length == 8 && + fb->canvas.green_offset == 8 && fb->canvas.green_length == 8 && + fb->canvas.blue_offset == 16 && fb->canvas.blue_length == 8) { + fb->canvas.rgbmode = BGR888; } else { - fb->rgbmode = GENERIC; + fb->canvas.rgbmode = GENERIC; } DBG("width: %i, height: %i, bpp: %i, stride: %i", - fb->width, fb->height, fb->bpp, fb->stride); + fb->canvas.width, fb->canvas.height, fb->canvas.bpp, fb->canvas.stride); fb->base = (char *) mmap ((caddr_t) NULL, fb_fix.smem_len, @@ -279,16 +280,17 @@ psplash_fb_new (int angle, int fbdev_id) if (fb->fb_var.yoffset == 0) { printf("to back\n"); fb->fdata = fb->data; - fb->bdata = fb->data + fb->stride * fb->height; + fb->bdata = fb->data + fb->canvas.stride * fb->canvas.height; } else { printf("to front\n"); - fb->fdata = fb->data + fb->stride * fb->height; + fb->fdata = fb->data + fb->canvas.stride * fb->canvas.height; fb->bdata = fb->data; } } else { fb->fdata = fb->data; fb->bdata = fb->data; } + fb->canvas.data = fb->bdata; #if 0 /* FIXME: No support for 8pp as yet */ @@ -312,14 +314,14 @@ psplash_fb_new (int angle, int fbdev_id) status = 2; #endif - fb->angle = angle; + fb->canvas.angle = angle; - switch (fb->angle) + switch (angle) { case 270: case 90: - fb->width = fb->real_height; - fb->height = fb->real_width; + fb->canvas.width = fb->real_height; + fb->canvas.height = fb->real_width; break; case 180: case 0: @@ -337,115 +339,6 @@ psplash_fb_new (int angle, int fbdev_id) return NULL; } -#define OFFSET(fb,x,y) (((y) * (fb)->stride) + ((x) * ((fb)->bpp >> 3))) - -static inline void -psplash_fb_plot_pixel (PSplashFB *fb, - int x, - int y, - uint8 red, - uint8 green, - uint8 blue) -{ - /* Always write to back data (bdata) which points to the right data with or - * without double buffering support */ - int off; - - if (x < 0 || x > fb->width-1 || y < 0 || y > fb->height-1) - return; - - switch (fb->angle) - { - case 270: - off = OFFSET (fb, fb->height - y - 1, x); - break; - case 180: - off = OFFSET (fb, fb->width - x - 1, fb->height - y - 1); - break; - case 90: - off = OFFSET (fb, y, fb->width - x - 1); - break; - case 0: - default: - off = OFFSET (fb, x, y); - break; - } - - if (fb->rgbmode == RGB565 || fb->rgbmode == RGB888) { - switch (fb->bpp) - { - case 24: -#if __BYTE_ORDER == __BIG_ENDIAN - *(fb->bdata + off + 0) = red; - *(fb->bdata + off + 1) = green; - *(fb->bdata + off + 2) = blue; -#else - *(fb->bdata + off + 0) = blue; - *(fb->bdata + off + 1) = green; - *(fb->bdata + off + 2) = red; -#endif - break; - case 32: - *(volatile uint32_t *) (fb->bdata + off) - = (red << 16) | (green << 8) | (blue); - break; - - case 16: - *(volatile uint16_t *) (fb->bdata + off) - = ((red >> 3) << 11) | ((green >> 2) << 5) | (blue >> 3); - break; - default: - /* depth not supported yet */ - break; - } - } else if (fb->rgbmode == BGR565 || fb->rgbmode == BGR888) { - switch (fb->bpp) - { - case 24: -#if __BYTE_ORDER == __BIG_ENDIAN - *(fb->bdata + off + 0) = blue; - *(fb->bdata + off + 1) = green; - *(fb->bdata + off + 2) = red; -#else - *(fb->bdata + off + 0) = red; - *(fb->bdata + off + 1) = green; - *(fb->bdata + off + 2) = blue; -#endif - break; - case 32: - *(volatile uint32_t *) (fb->bdata + off) - = (blue << 16) | (green << 8) | (red); - break; - case 16: - *(volatile uint16_t *) (fb->bdata + off) - = ((blue >> 3) << 11) | ((green >> 2) << 5) | (red >> 3); - break; - default: - /* depth not supported yet */ - break; - } - } else { - switch (fb->bpp) - { - case 32: - *(volatile uint32_t *) (fb->bdata + off) - = ((red >> (8 - fb->red_length)) << fb->red_offset) - | ((green >> (8 - fb->green_length)) << fb->green_offset) - | ((blue >> (8 - fb->blue_length)) << fb->blue_offset); - break; - case 16: - *(volatile uint16_t *) (fb->bdata + off) - = ((red >> (8 - fb->red_length)) << fb->red_offset) - | ((green >> (8 - fb->green_length)) << fb->green_offset) - | ((blue >> (8 - fb->blue_length)) << fb->blue_offset); - break; - default: - /* depth not supported yet */ - break; - } - } -} - void psplash_fb_draw_rect (PSplashFB *fb, int x, @@ -460,7 +353,7 @@ psplash_fb_draw_rect (PSplashFB *fb, for (dy=0; dy < height; dy++) for (dx=0; dx < width; dx++) - psplash_fb_plot_pixel (fb, x+dx, y+dy, red, green, blue); + psplash_plot_pixel(&fb->canvas, x+dx, y+dy, red, green, blue); } void @@ -493,7 +386,7 @@ psplash_fb_draw_image (PSplashFB *fb, do { if ((img_bytes_per_pixel < 4 || *(p+3)) && dx < img_width) - psplash_fb_plot_pixel (fb, x+dx, y+dy, *(p), *(p+1), *(p+2)); + psplash_plot_pixel(&fb->canvas, x+dx, y+dy, *(p), *(p+1), *(p+2)); if (++dx * img_bytes_per_pixel >= img_rowstride) { dx=0; dy++; } } while (--len); @@ -507,7 +400,7 @@ psplash_fb_draw_image (PSplashFB *fb, do { if ((img_bytes_per_pixel < 4 || *(p+3)) && dx < img_width) - psplash_fb_plot_pixel (fb, x+dx, y+dy, *(p), *(p+1), *(p+2)); + psplash_plot_pixel(&fb->canvas, x+dx, y+dy, *(p), *(p+1), *(p+2)); if (++dx * img_bytes_per_pixel >= img_rowstride) { dx=0; dy++; } p += img_bytes_per_pixel; } @@ -613,7 +506,7 @@ psplash_fb_draw_text (PSplashFB *fb, for (cx = 0; cx < w; cx++) { if (g & 0x80000000) - psplash_fb_plot_pixel (fb, x+dx+cx, y+dy+cy, + psplash_plot_pixel(&fb->canvas, x+dx+cx, y+dy+cy, red, green, blue); g <<= 1; } diff --git a/psplash-fb.h b/psplash-fb.h index 4d5c460..eb02c62 100644 --- a/psplash-fb.h +++ b/psplash-fb.h @@ -11,25 +11,16 @@ #define _HAVE_PSPLASH_FB_H #include -#include "psplash.h" - -enum RGBMode { - RGB565, - BGR565, - RGB888, - BGR888, - GENERIC, -}; +#include "psplash-draw.h" typedef struct PSplashFB { + PSplashCanvas canvas; + int fd; struct fb_var_screeninfo fb_var; int type; int visual; - int width, height; - int bpp; - int stride; char *data; char *base; @@ -38,16 +29,8 @@ typedef struct PSplashFB char *bdata; char *fdata; - int angle, fbdev_id; + int fbdev_id; int real_width, real_height; - - enum RGBMode rgbmode; - int red_offset; - int red_length; - int green_offset; - int green_length; - int blue_offset; - int blue_length; } PSplashFB; diff --git a/psplash.c b/psplash.c index 18c012b..f23f03d 100644 --- a/psplash.c +++ b/psplash.c @@ -22,10 +22,10 @@ #include FONT_HEADER #define SPLIT_LINE_POS(fb) \ - ( (fb)->height \ + ( (fb)->canvas.height \ - (( PSPLASH_IMG_SPLIT_DENOMINATOR \ - PSPLASH_IMG_SPLIT_NUMERATOR) \ - * (fb)->height / PSPLASH_IMG_SPLIT_DENOMINATOR) \ + * (fb)->canvas.height / PSPLASH_IMG_SPLIT_DENOMINATOR) \ ) void @@ -50,12 +50,12 @@ psplash_draw_msg (PSplashFB *fb, const char *msg) psplash_fb_draw_rect (fb, 0, SPLIT_LINE_POS(fb) - h, - fb->width, + fb->canvas.width, h, PSPLASH_BACKGROUND_COLOR); psplash_fb_draw_text (fb, - (fb->width-w)/2, + (fb->canvas.width-w)/2, SPLIT_LINE_POS(fb) - h, PSPLASH_TEXT_COLOR, &FONT_DEF, @@ -69,7 +69,7 @@ psplash_draw_progress (PSplashFB *fb, int value) int x, y, width, height, barwidth; /* 4 pix border */ - x = ((fb->width - BAR_IMG_WIDTH)/2) + 4 ; + x = ((fb->canvas.width - BAR_IMG_WIDTH)/2) + 4 ; y = SPLIT_LINE_POS(fb) + 4; width = BAR_IMG_WIDTH - 8; height = BAR_IMG_HEIGHT - 8; @@ -301,16 +301,16 @@ main (int argc, char** argv) #endif /* Clear the background with #ecece1 */ - psplash_fb_draw_rect (fb, 0, 0, fb->width, fb->height, + psplash_fb_draw_rect (fb, 0, 0, fb->canvas.width, fb->canvas.height, PSPLASH_BACKGROUND_COLOR); /* Draw the Poky logo */ psplash_fb_draw_image (fb, - (fb->width - POKY_IMG_WIDTH)/2, + (fb->canvas.width - POKY_IMG_WIDTH)/2, #if PSPLASH_IMG_FULLSCREEN - (fb->height - POKY_IMG_HEIGHT)/2, + (fb->canvas.height - POKY_IMG_HEIGHT)/2, #else - (fb->height * PSPLASH_IMG_SPLIT_NUMERATOR + (fb->canvas.height * PSPLASH_IMG_SPLIT_NUMERATOR / PSPLASH_IMG_SPLIT_DENOMINATOR - POKY_IMG_HEIGHT)/2, #endif POKY_IMG_WIDTH, @@ -322,7 +322,7 @@ main (int argc, char** argv) #ifdef PSPLASH_SHOW_PROGRESS_BAR /* Draw progress bar border */ psplash_fb_draw_image (fb, - (fb->width - BAR_IMG_WIDTH)/2, + (fb->canvas.width - BAR_IMG_WIDTH)/2, SPLIT_LINE_POS(fb), BAR_IMG_WIDTH, BAR_IMG_HEIGHT, From patchwork Mon Apr 25 07:59:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasyl Vavrychuk X-Patchwork-Id: 7081 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56DDBC49EA4 for ; Mon, 25 Apr 2022 19:26:13 +0000 (UTC) Received: from repost01.tmes.trendmicro.eu (repost01.tmes.trendmicro.eu [18.185.115.8]) by mx.groups.io with SMTP id smtpd.web09.26982.1650873626045359599 for ; Mon, 25 Apr 2022 01:00:27 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@opensynergy.com header.s=tm-dkim-20210503141657 header.b=z1QfLzin; spf=pass (domain: opensynergy.com, ip: 18.185.115.8, mailfrom: vasyl.vavrychuk@opensynergy.com) Received: from 104.47.12.56_.trendmicro.com (unknown [172.21.180.2]) by repost01.tmes.trendmicro.eu (Postfix) with SMTP id 3A20210001756 for ; Mon, 25 Apr 2022 08:00:24 +0000 (UTC) X-TM-MAIL-RECEIVED-TIME: 1650873623.699000 X-TM-MAIL-UUID: 96cca8a8-38e4-49ac-96ff-a981754ee4e0 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (unknown [104.47.12.56]) by repre01.tmes.trendmicro.eu (Trend Micro Email Security) with ESMTPS id AABF1100010B0 for ; Mon, 25 Apr 2022 08:00:23 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YVoKV7p569WIyocwVSFmtrdeAO7WSGv9BNvSf9fvs0DWDplabwaWqYQQvfahPDjUIcqzc5ZZwdniT95VVYrvcFH38PZ5w+wgO7AlpcN0B0giFBtpMHK+DKuUTMnCxpifzUwpGpaGusxc7D3W+FtuwOPR42WosmQa56Dx7USfs2ea4TijtR1cr6K4gyxxos5lPd5LpRekzN+mmdxTIANCS6ZsvM+1F6ShPxtrGghG9J3w83C3ZZ+O1PoFaD30CLjgocABxhblWRQ6AbWSQHHJ1Wg4pHJO4NBLy305Xzg1ESJY648xjF0Yf/jtMrWsagYeKR0R8M5Y6H14QVKZy0ClkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3tRcmY/na5QFlqqRFunqrjnnidur0xfdCfZdfZfz94E=; b=FhnAp84WnVndy1LwWqg9L4W9xUo6tWe+MSExOPNRtReb7CfzjDiBj9alz7JiQscjLjfHs4FIBRBuyzOgNmCEeJNNv2wbQeVRGM+rMdv5zb3lEnh8uLP0PaK/J/mU02Mmn1USveLDhNo2p3tvuHb0itHZCgjy95j2a9kwJuCztvlsY4m0Zqe5JeVrhTLrKajH/cb7W5l+X9rMfr9PgM42Cb9wQ7Vw7IWj3XuCCUc49mJFTFcESHgYrq6YrIQ9vV7x19yWMuVcw76iU11x9xhlSXWuM+/ihNPwFvQbnfhwyfQwA4xhF5yuX2o8x4Wr6Ab9E2rb9yxeEJBq5MnwqfpyYw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 217.66.60.4) smtp.rcpttodomain=lists.yoctoproject.org smtp.mailfrom=opensynergy.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=opensynergy.com; dkim=none (message not signed); arc=none X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 217.66.60.4) smtp.mailfrom=opensynergy.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=opensynergy.com; Received-SPF: Pass (protection.outlook.com: domain of opensynergy.com designates 217.66.60.4 as permitted sender) receiver=protection.outlook.com; client-ip=217.66.60.4; helo=SR-MAIL-03.open-synergy.com; From: Vasyl Vavrychuk To: yocto@lists.yoctoproject.org Cc: Vasyl Vavrychuk Subject: [psplash][RFC PATCH 06/14] Extract draw rect/image from psplash-fb Date: Mon, 25 Apr 2022 10:59:46 +0300 Message-Id: <20220425075954.10427-7-vasyl.vavrychuk@opensynergy.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220425075954.10427-1-vasyl.vavrychuk@opensynergy.com> References: <20220425075954.10427-1-vasyl.vavrychuk@opensynergy.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 53428d5a-bb44-4070-1f28-08da2691a531 X-MS-TrafficTypeDiagnostic: DBAPR04MB7415:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZKqp38FQmL5pWmU6nFDXUxdJmvJqcIUiMgA6tUQt9OfO3fZBalWQUbCcYSkwFotLitiW2w/z2T0R71l7LAQy1RyQfXaGW311bfBnxuNktSnavKW0qufGuUfJCAniKIy12WniEkjMwGr6NmP0mLQQbfKWmLNnIgKIrTwgzuUds5k8eDpVdBpNvb2idIv4dlthrPWMq42bJIaYYh3IO+zHGvZDsAWI/Oxbyb0u8OSN5M/58hsM9eo+ZiGs6FfiZhdWtZVHdKafA7NggKenGNe6Z5U9mYPYVUSC1pjUat3MoWwa1xoxRDqybvGiq4Ff31npkvwY87i6pngG0DdF71YSMsKi76oXzo8ZwfaNnF3ccSHsokcYOafZamZMZT6MJVfoXBnKYT43r77SBhD0inCnC/NUf0yfcuOeEHx7b0Q2x0SJ94MS+kZSfKf0R5qH2C/WqlXRA7gV+TE5+PtV6rBmAfGwQ06DrpLQDeenOWYtshWwHS+PGHJuqvZ/KaudMMr0PN8v6IJvCjVG+D6l2gaOHM/i8F4/HBZk7VEZR2o4UqZRbnBWQlhW0p5qEG8Nb3D0FjCGK8Mm1IqV+PzmY4vbY6Cm4yhT8rcpEQ+s0gJgyz1mLvvOXSgUHIrrKyc2R4iwnAuno3Pcus3AS6Yqc+9De7fpiWmrS5oPzYQgVJR5CSc= X-Forefront-Antispam-Report: CIP:217.66.60.4;CTRY:DE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SR-MAIL-03.open-synergy.com;PTR:mx1.opensynergy.com;CAT:NONE;SFS:(13230001)(396003)(136003)(346002)(376002)(39830400003)(46966006)(36840700001)(107886003)(1076003)(40480700001)(186003)(2906002)(5660300002)(86362001)(26005)(70206006)(4326008)(8676002)(70586007)(2616005)(8936002)(508600001)(82310400005)(42186006)(83380400001)(6916009)(336012)(81166007)(36756003)(36860700001)(44832011)(316002)(47076005);DIR:OUT;SFP:1102; X-OriginatorOrg: opensynergy.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2022 08:00:20.9138 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 53428d5a-bb44-4070-1f28-08da2691a531 X-MS-Exchange-CrossTenant-Id: 800fae25-9b1b-4edc-993d-c939c4e84a64 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=800fae25-9b1b-4edc-993d-c939c4e84a64;Ip=[217.66.60.4];Helo=[SR-MAIL-03.open-synergy.com] X-MS-Exchange-CrossTenant-AuthSource: VI1EUR05FT039.eop-eur05.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR04MB7415 X-TM-AS-ERS: 104.47.12.56-0.0.0.0 X-TMASE-Version: StarCloud-1.3-8.8.1001-26854.006 X-TMASE-Result: 10--0.645700-4.000000 X-TMASE-MatchedRID: tgaipGrys3i1UOlz1sLXchF4zyLyne+ATJDl9FKHbrlAglB4aYxV4jhn UdH7vK7s76cfT8R97tpUdifX/ssRD8iuP7JEgBPGSHCU59h5KrEpA2ExuipmWq25ZjP2hWgvO4d dIrW9yRVtGpev2mVwX69odUR5cJBxVZwLM6NBHzSfNCkqvupbSEpO/ORUaZ3FmyiLZetSf8m2Ie O/ulJw0ft6/2HgfIgDVymkLM+r7VQ7AFczfjr/7OdSQRkaJTbL0izjYg8nXOv7NIDR7nyBmhZpU GdMmLK9z0ilKrutyKM= X-TMASE-XGENCLOUD: 4ad741bb-177b-4d59-8a7e-68d156ad5150-0-0-200-0 X-TM-Deliver-Signature: 5F680C76AC0F4443A8C73B64BEB58772 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=opensynergy.com; s=TM-DKIM-20210503141657; t=1650873624; bh=UpKZ4cUegiIJo6y7GnBEvWVT+0hqd84auIRFV+/Q8OM=; l=8033; h=From:To:Date; b=z1QfLzin7xz2pad7XjcT4EFODFV53Ab8SrLP3OAEHR6Ai68XUB5MFuAk8AV66DQE6 fTyDkqaSPWxl556HVexlkR3lZsM8tf5Nrh6dFOuJCLKm6K0cVGGPE7pdWqhH/h4eH7 MKshptH7dVrfnmC7wFdem1ouFErU0Twgqr186GPMGrCD5Ld+ETMeiMW3GAoESjciXM ArKl2zqTY6VV1rHiOCm6keTPThhSL+u3Ult3KskrMq4optpkuGAbN9+z+qZFajmF9s /BMDedB3lRJX5yWdaZwDMe81HSO7pW6gNWmmIvbc8QB9+xkNG14hUGadVWz9fCunSd 3qeuf3BcWjuRw== List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 25 Apr 2022 19:26:13 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto/message/56863 Signed-off-by: Vasyl Vavrychuk --- psplash-draw.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++ psplash-draw.h | 20 +++++++++++++++ psplash-fb.c | 70 -------------------------------------------------- psplash-fb.h | 20 --------------- psplash.c | 16 ++++++------ 5 files changed, 98 insertions(+), 98 deletions(-) diff --git a/psplash-draw.c b/psplash-draw.c index 570cfce..6887e22 100644 --- a/psplash-draw.c +++ b/psplash-draw.c @@ -118,3 +118,73 @@ psplash_plot_pixel(PSplashCanvas *canvas, } } } + +void +psplash_draw_rect(PSplashCanvas *canvas, + int x, + int y, + int width, + int height, + uint8 red, + uint8 green, + uint8 blue) +{ + int dx, dy; + + for (dy=0; dy < height; dy++) + for (dx=0; dx < width; dx++) + psplash_plot_pixel(canvas, x+dx, y+dy, red, green, blue); +} + +void +psplash_draw_image(PSplashCanvas *canvas, + int x, + int y, + int img_width, + int img_height, + int img_bytes_per_pixel, + int img_rowstride, + uint8 *rle_data) +{ + uint8 *p = rle_data; + int dx = 0, dy = 0, total_len; + unsigned int len; + + total_len = img_rowstride * img_height; + + /* FIXME: Optimise, check for over runs ... */ + while ((p - rle_data) < total_len) + { + len = *(p++); + + if (len & 128) + { + len -= 128; + + if (len == 0) break; + + do + { + if ((img_bytes_per_pixel < 4 || *(p+3)) && dx < img_width) + psplash_plot_pixel(canvas, x+dx, y+dy, *(p), *(p+1), *(p+2)); + if (++dx * img_bytes_per_pixel >= img_rowstride) { dx=0; dy++; } + } + while (--len); + + p += img_bytes_per_pixel; + } + else + { + if (len == 0) break; + + do + { + if ((img_bytes_per_pixel < 4 || *(p+3)) && dx < img_width) + psplash_plot_pixel(canvas, x+dx, y+dy, *(p), *(p+1), *(p+2)); + if (++dx * img_bytes_per_pixel >= img_rowstride) { dx=0; dy++; } + p += img_bytes_per_pixel; + } + while (--len && (p - rle_data) < total_len); + } + } +} diff --git a/psplash-draw.h b/psplash-draw.h index ab2d4d2..f8361da 100644 --- a/psplash-draw.h +++ b/psplash-draw.h @@ -48,4 +48,24 @@ psplash_plot_pixel(PSplashCanvas *canvas, uint8 green, uint8 blue); +void +psplash_draw_rect(PSplashCanvas *canvas, + int x, + int y, + int width, + int height, + uint8 red, + uint8 green, + uint8 blue); + +void +psplash_draw_image(PSplashCanvas *canvas, + int x, + int y, + int img_width, + int img_height, + int img_bytes_per_pixel, + int img_rowstride, + uint8 *rle_data); + #endif diff --git a/psplash-fb.c b/psplash-fb.c index a7029c5..07839d5 100644 --- a/psplash-fb.c +++ b/psplash-fb.c @@ -339,76 +339,6 @@ psplash_fb_new (int angle, int fbdev_id) return NULL; } -void -psplash_fb_draw_rect (PSplashFB *fb, - int x, - int y, - int width, - int height, - uint8 red, - uint8 green, - uint8 blue) -{ - int dx, dy; - - for (dy=0; dy < height; dy++) - for (dx=0; dx < width; dx++) - psplash_plot_pixel(&fb->canvas, x+dx, y+dy, red, green, blue); -} - -void -psplash_fb_draw_image (PSplashFB *fb, - int x, - int y, - int img_width, - int img_height, - int img_bytes_per_pixel, - int img_rowstride, - uint8 *rle_data) -{ - uint8 *p = rle_data; - int dx = 0, dy = 0, total_len; - unsigned int len; - - total_len = img_rowstride * img_height; - - /* FIXME: Optimise, check for over runs ... */ - while ((p - rle_data) < total_len) - { - len = *(p++); - - if (len & 128) - { - len -= 128; - - if (len == 0) break; - - do - { - if ((img_bytes_per_pixel < 4 || *(p+3)) && dx < img_width) - psplash_plot_pixel(&fb->canvas, x+dx, y+dy, *(p), *(p+1), *(p+2)); - if (++dx * img_bytes_per_pixel >= img_rowstride) { dx=0; dy++; } - } - while (--len); - - p += img_bytes_per_pixel; - } - else - { - if (len == 0) break; - - do - { - if ((img_bytes_per_pixel < 4 || *(p+3)) && dx < img_width) - psplash_plot_pixel(&fb->canvas, x+dx, y+dy, *(p), *(p+1), *(p+2)); - if (++dx * img_bytes_per_pixel >= img_rowstride) { dx=0; dy++; } - p += img_bytes_per_pixel; - } - while (--len && (p - rle_data) < total_len); - } - } -} - /* Font rendering code based on BOGL by Ben Pfaff */ static int diff --git a/psplash-fb.h b/psplash-fb.h index eb02c62..1eecb47 100644 --- a/psplash-fb.h +++ b/psplash-fb.h @@ -40,26 +40,6 @@ psplash_fb_destroy (PSplashFB *fb); PSplashFB* psplash_fb_new (int angle, int fbdev_id); -void -psplash_fb_draw_rect (PSplashFB *fb, - int x, - int y, - int width, - int height, - uint8 red, - uint8 green, - uint8 blue); - -void -psplash_fb_draw_image (PSplashFB *fb, - int x, - int y, - int img_width, - int img_height, - int img_bytes_pre_pixel, - int img_rowstride, - uint8 *rle_data); - void psplash_fb_text_size (int *width, int *height, diff --git a/psplash.c b/psplash.c index f23f03d..2aeb583 100644 --- a/psplash.c +++ b/psplash.c @@ -47,7 +47,7 @@ psplash_draw_msg (PSplashFB *fb, const char *msg) /* Clear */ - psplash_fb_draw_rect (fb, + psplash_draw_rect(&fb->canvas, 0, SPLIT_LINE_POS(fb) - h, fb->canvas.width, @@ -77,19 +77,19 @@ psplash_draw_progress (PSplashFB *fb, int value) if (value > 0) { barwidth = (CLAMP(value,0,100) * width) / 100; - psplash_fb_draw_rect (fb, x + barwidth, y, + psplash_draw_rect(&fb->canvas, x + barwidth, y, width - barwidth, height, PSPLASH_BAR_BACKGROUND_COLOR); - psplash_fb_draw_rect (fb, x, y, barwidth, + psplash_draw_rect(&fb->canvas, x, y, barwidth, height, PSPLASH_BAR_COLOR); } else { barwidth = (CLAMP(-value,0,100) * width) / 100; - psplash_fb_draw_rect (fb, x, y, + psplash_draw_rect(&fb->canvas, x, y, width - barwidth, height, PSPLASH_BAR_BACKGROUND_COLOR); - psplash_fb_draw_rect (fb, x + width - barwidth, + psplash_draw_rect(&fb->canvas, x + width - barwidth, y, barwidth, height, PSPLASH_BAR_COLOR); } @@ -301,11 +301,11 @@ main (int argc, char** argv) #endif /* Clear the background with #ecece1 */ - psplash_fb_draw_rect (fb, 0, 0, fb->canvas.width, fb->canvas.height, + psplash_draw_rect(&fb->canvas, 0, 0, fb->canvas.width, fb->canvas.height, PSPLASH_BACKGROUND_COLOR); /* Draw the Poky logo */ - psplash_fb_draw_image (fb, + psplash_draw_image(&fb->canvas, (fb->canvas.width - POKY_IMG_WIDTH)/2, #if PSPLASH_IMG_FULLSCREEN (fb->canvas.height - POKY_IMG_HEIGHT)/2, @@ -321,7 +321,7 @@ main (int argc, char** argv) #ifdef PSPLASH_SHOW_PROGRESS_BAR /* Draw progress bar border */ - psplash_fb_draw_image (fb, + psplash_draw_image(&fb->canvas, (fb->canvas.width - BAR_IMG_WIDTH)/2, SPLIT_LINE_POS(fb), BAR_IMG_WIDTH, From patchwork Mon Apr 25 07:59:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasyl Vavrychuk X-Patchwork-Id: 7082 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63A42C54EC4 for ; Mon, 25 Apr 2022 19:26:13 +0000 (UTC) Received: from repost01.tmes.trendmicro.eu (repost01.tmes.trendmicro.eu [18.185.115.31]) by mx.groups.io with SMTP id smtpd.web09.26983.1650873626369858797 for ; Mon, 25 Apr 2022 01:00:27 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@opensynergy.com header.s=tm-dkim-20210503141657 header.b=fFWgbkPj; spf=pass (domain: opensynergy.com, ip: 18.185.115.31, mailfrom: vasyl.vavrychuk@opensynergy.com) Received: from 104.47.14.58_.trendmicro.com (unknown [172.21.163.172]) by repost01.tmes.trendmicro.eu (Postfix) with SMTP id 0814010000BDE for ; Mon, 25 Apr 2022 08:00:25 +0000 (UTC) X-TM-MAIL-RECEIVED-TIME: 1650873624.339000 X-TM-MAIL-UUID: 5319408f-23f1-4bd2-be07-c9eb8d7cc9e1 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (unknown [104.47.14.58]) by repre01.tmes.trendmicro.eu (Trend Micro Email Security) with ESMTPS id 52ECE100010B0 for ; Mon, 25 Apr 2022 08:00:24 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SVpldZvBQb6Q7p2xiXvua7GrEIK8XqNV7SBc10r9Cg4dx3qYgiWiK7X773gbpn6fMhejyAg1qpJ3AfWgFfWycTwTw0be9a20BI9Qnk3hg7oRRS0Q4Q/9BBvBH41sVaepq+Zw0DmJ0U4tlIY55+0yvZggCR0zvnKDrwT/Ov3PWD5b4ep+rC8e4N4D3jpzbWJEFP/atEzzq9rndMhwDbHJ5+YTJciOiaaKCnBltkjK0L/8UWhUhbhyN4I/eqGYrrH/lAwTlXW6A1hLH1GM5WFv39hui6fOizchwpwJugYp7f7xa16zxsp/gAawzobMYL8Ch1gs8GDxbRgGHGumE0ZDrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lUS1w6ev0HMfCB8lWjBi64Y4X3B1rkQyWYj62s98HHc=; b=WNjeXkZQHRk5Upox/ROti/bcnn9LDbK7VYqYTm05FLe/bVQ3ivimBVKoDcFHEhAsdC89Roy72/WnrArmbiJlvbcxXsolYTjMv2LztDk0meLmmIy37IVtGdhoXh1APTM4laJKx+zZLAru5EHurmBuETJjaHky88lHxC21Wh0zGxRIm1TQCHdJ7D/t3QBuJJplIZ8SFgQvK64FeIWWXYyIA9g1whYCl7Ek4dybbKYJT2QPJ2aMssma3UumeHwQItpstMxM5HF9f0n0kfcLOd7Fhb/+SfgYtuK67tucnFcLPozYOuqQoS1IVBwv6/xByrn0E2Vu6F/5G6N43njpJJAJPQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 217.66.60.4) smtp.rcpttodomain=lists.yoctoproject.org smtp.mailfrom=opensynergy.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=opensynergy.com; dkim=none (message not signed); arc=none X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 217.66.60.4) smtp.mailfrom=opensynergy.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=opensynergy.com; Received-SPF: Pass (protection.outlook.com: domain of opensynergy.com designates 217.66.60.4 as permitted sender) receiver=protection.outlook.com; client-ip=217.66.60.4; helo=SR-MAIL-03.open-synergy.com; From: Vasyl Vavrychuk To: yocto@lists.yoctoproject.org Cc: Vasyl Vavrychuk Subject: [psplash][RFC PATCH 07/14] Extract draw font from psplash-fb Date: Mon, 25 Apr 2022 10:59:47 +0300 Message-Id: <20220425075954.10427-8-vasyl.vavrychuk@opensynergy.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220425075954.10427-1-vasyl.vavrychuk@opensynergy.com> References: <20220425075954.10427-1-vasyl.vavrychuk@opensynergy.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d4538494-0a24-4304-1d32-08da2691a559 X-MS-TrafficTypeDiagnostic: AM0PR04MB6898:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ENFS7y2dUWYZ8EF0pZ5HqRHlEU+Hv766jsJeVRjfagk6ONLRTtlapDXrgwSB0WF7/ZBFBM057kZFXJB4onT49skCHuPghZ0YcHvWBoPSM/zBvmyi0bI1IjNd8Uu17flq4VqlFgVxnklMjtBhq8v0uHODJaorXvJ/+jAhZleI3lBljUoZYRTqwuKCR5RNLhSiYEs8IoHJ8hIgNg2eh80oKSYTU0dmu3ZM+S8+LmA+h+I4HTpPoUI7EkHgAfQN3J5MsK5VB49vksJ/2DRUPoMEmdG/59Cx90pWcSUaeXb2OoWypckiM4rrjLHlk3p+65o7N/D34JrKzI/MeIM225Jj0pGBrUnJ6xBriZC1t/MUsj1XaxLdPqg6w/zFCvuRW2LNsLZdk+6sj9tQ3gab3NDgjnr5UIX7sfHnACec4b458sz9Un2QIONDB58qxO+qLW5/pbJJMiQ32IfnK795K14bo/iNfEMSIgiufi/63n8+6BptPV1B+FErXvfEEvAkJk8TQy5k6H4BWRI19SBY1G3kU9ThkdsVfIXXgJ8s5ZflI3Bt14Hw5vKtOum+2t6XMwMP+EpPH7natqCKw2Ild0dBQrjbSZKx881ASrBPF6OvdYuj2vc0VVpyXLUZI/PdXPsWAiDZMSERqfi/3AJwcQVVfvTA5PeFqYYMst3CNYHPwJ61KVzG7BVEt2Fax5uNjI0q X-Forefront-Antispam-Report: CIP:217.66.60.4;CTRY:DE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SR-MAIL-03.open-synergy.com;PTR:mx1.opensynergy.com;CAT:NONE;SFS:(13230001)(396003)(39830400003)(376002)(136003)(346002)(46966006)(36840700001)(4326008)(2906002)(40480700001)(8676002)(5660300002)(508600001)(107886003)(2616005)(336012)(186003)(83380400001)(47076005)(1076003)(86362001)(8936002)(82310400005)(26005)(36860700001)(70206006)(70586007)(6916009)(81166007)(316002)(42186006)(44832011)(36756003);DIR:OUT;SFP:1102; X-OriginatorOrg: opensynergy.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2022 08:00:21.1759 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d4538494-0a24-4304-1d32-08da2691a559 X-MS-Exchange-CrossTenant-Id: 800fae25-9b1b-4edc-993d-c939c4e84a64 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=800fae25-9b1b-4edc-993d-c939c4e84a64;Ip=[217.66.60.4];Helo=[SR-MAIL-03.open-synergy.com] X-MS-Exchange-CrossTenant-AuthSource: VI1EUR05FT024.eop-eur05.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6898 X-TM-AS-ERS: 104.47.14.58-0.0.0.0 X-TMASE-Version: StarCloud-1.3-8.8.1001-26854.006 X-TMASE-Result: 10--3.091300-4.000000 X-TMASE-MatchedRID: +rFemiuRQom1UOlz1sLXchF4zyLyne+ATJDl9FKHbrmqA3rusLu26qnM w2roCh9qhPscUcu6CfxpsU1us5N/4flhKX4Mv8JUSs47mbT7SASISKNNH1lESd9RjZujPiSk9zD JVgZmvsjY4Fl6uZXggNXoG9vFAKs3uWAlzT4Obx4K3Ma88LL+buOaAxDXuHnr3MX35z3GRpvT3f 37uQB4Lugc6mX1lwNHkRoxEQkO3VF1H8bw68oiD23U7j2vVURrxEHRux+uk8h+ICquNi0WJLiXd lupaFev7x5lC7m4+c6vVKGGaqVeCrbVKBuwEg48ftwZ3X11IV0= X-TMASE-XGENCLOUD: 67a876ae-a5a8-4848-bdfe-57d2c7615526-0-0-200-0 X-TM-Deliver-Signature: A9437BBFD0E33C8551D71E9B85FEA3A9 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=opensynergy.com; s=TM-DKIM-20210503141657; t=1650873624; bh=BoQ8wBylaPtF0d0c9QQvQzno/tOg6fEq78qhEdFLQx8=; l=7919; h=From:To:Date; b=fFWgbkPjv3YfWthh/xovH27KN1c+GFaGs5HZMsxFrALnS9MiBU+DJ7qF78tUSXBug RoYMpdO3XDqIBBhk8WKof+mkem22eKyZffJxKSaK60IxX+oTrVRmDbMVUwxDdRcu1H zuGOG/4abeNRFgMQzkQ+OVhAdtgTG21sTZ28KGYIzxrnHd5ltVdfR6rJ8kLkJjeeap ho/0ynxMABz5AE0OIfxQ0iZYo6Cog8iynslP9sc8hmArnfvyn/cycKWKLnJ3hiaFUB ZjnnE+dYBP9oGt0sZgixnEWIRc2gqU7k/5qEtIZas/fJHN44KqxFlBJaYKWhcilZWV z8Z2CZcN/eHXQ== List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 25 Apr 2022 19:26:13 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto/message/56864 Signed-off-by: Vasyl Vavrychuk --- psplash-draw.c | 109 ++++++++++++++++++++++++++++++++++++++++++++++++- psplash-draw.h | 25 ++++++++---- psplash-fb.c | 108 ------------------------------------------------ psplash-fb.h | 16 -------- psplash.c | 4 +- 5 files changed, 125 insertions(+), 137 deletions(-) diff --git a/psplash-draw.c b/psplash-draw.c index 6887e22..aa9887a 100644 --- a/psplash-draw.c +++ b/psplash-draw.c @@ -11,8 +11,7 @@ #define OFFSET(canvas, x, y) (((y) * (canvas)->stride) + ((x) * ((canvas)->bpp >> 3))) -/* TODO: change to 'static inline' as psplash_fb_plot_pixel was before */ -void +static inline void psplash_plot_pixel(PSplashCanvas *canvas, int x, int y, @@ -188,3 +187,109 @@ psplash_draw_image(PSplashCanvas *canvas, } } } + +/* Font rendering code based on BOGL by Ben Pfaff */ + +static int +psplash_font_glyph (const PSplashFont *font, wchar_t wc, u_int32_t **bitmap) +{ + int mask = font->index_mask; + int i; + + for (;;) + { + for (i = font->offset[wc & mask]; font->index[i]; i += 2) + { + if ((wchar_t)(font->index[i] & ~mask) == (wc & ~mask)) + { + if (bitmap != NULL) + *bitmap = &font->content[font->index[i+1]]; + return font->index[i] & mask; + } + } + } + return 0; +} + +void +psplash_text_size(int *width, + int *height, + const PSplashFont *font, + const char *text) +{ + char *c = (char*)text; + wchar_t wc; + int k, n, w, h, mw; + + n = strlen (text); + mw = h = w = 0; + + mbtowc (0, 0, 0); + for (; (k = mbtowc (&wc, c, n)) > 0; c += k, n -= k) + { + if (*c == '\n') + { + if (w > mw) + mw = w; + w = 0; + h += font->height; + continue; + } + + w += psplash_font_glyph (font, wc, NULL); + } + + *width = (w > mw) ? w : mw; + *height = (h == 0) ? font->height : h; +} + +void +psplash_draw_text(PSplashCanvas *canvas, + int x, + int y, + uint8 red, + uint8 green, + uint8 blue, + const PSplashFont *font, + const char *text) +{ + int h, w, k, n, cx, cy, dx, dy; + char *c = (char*)text; + wchar_t wc; + + n = strlen (text); + h = font->height; + dx = dy = 0; + + mbtowc (0, 0, 0); + for (; (k = mbtowc (&wc, c, n)) > 0; c += k, n -= k) + { + u_int32_t *glyph = NULL; + + if (*c == '\n') + { + dy += h; + dx = 0; + continue; + } + + w = psplash_font_glyph (font, wc, &glyph); + + if (glyph == NULL) + continue; + + for (cy = 0; cy < h; cy++) + { + u_int32_t g = *glyph++; + + for (cx = 0; cx < w; cx++) + { + if (g & 0x80000000) + psplash_plot_pixel(canvas, x+dx+cx, y+dy+cy, red, green, blue); + g <<= 1; + } + } + + dx += w; + } +} diff --git a/psplash-draw.h b/psplash-draw.h index f8361da..44546b0 100644 --- a/psplash-draw.h +++ b/psplash-draw.h @@ -39,15 +39,6 @@ typedef struct PSplashCanvas } PSplashCanvas; -/* TODO: Remove after rest of drawing functions migrated to psplash-draw.c */ -void -psplash_plot_pixel(PSplashCanvas *canvas, - int x, - int y, - uint8 red, - uint8 green, - uint8 blue); - void psplash_draw_rect(PSplashCanvas *canvas, int x, @@ -68,4 +59,20 @@ psplash_draw_image(PSplashCanvas *canvas, int img_rowstride, uint8 *rle_data); +void +psplash_text_size(int *width, + int *height, + const PSplashFont *font, + const char *text); + +void +psplash_draw_text(PSplashCanvas *canvas, + int x, + int y, + uint8 red, + uint8 green, + uint8 blue, + const PSplashFont *font, + const char *text); + #endif diff --git a/psplash-fb.c b/psplash-fb.c index 07839d5..dd50a5a 100644 --- a/psplash-fb.c +++ b/psplash-fb.c @@ -338,111 +338,3 @@ psplash_fb_new (int angle, int fbdev_id) return NULL; } - -/* Font rendering code based on BOGL by Ben Pfaff */ - -static int -psplash_font_glyph (const PSplashFont *font, wchar_t wc, u_int32_t **bitmap) -{ - int mask = font->index_mask; - int i; - - for (;;) - { - for (i = font->offset[wc & mask]; font->index[i]; i += 2) - { - if ((wchar_t)(font->index[i] & ~mask) == (wc & ~mask)) - { - if (bitmap != NULL) - *bitmap = &font->content[font->index[i+1]]; - return font->index[i] & mask; - } - } - } - return 0; -} - -void -psplash_fb_text_size (int *width, - int *height, - const PSplashFont *font, - const char *text) -{ - char *c = (char*)text; - wchar_t wc; - int k, n, w, h, mw; - - n = strlen (text); - mw = h = w = 0; - - mbtowc (0, 0, 0); - for (; (k = mbtowc (&wc, c, n)) > 0; c += k, n -= k) - { - if (*c == '\n') - { - if (w > mw) - mw = w; - w = 0; - h += font->height; - continue; - } - - w += psplash_font_glyph (font, wc, NULL); - } - - *width = (w > mw) ? w : mw; - *height = (h == 0) ? font->height : h; -} - -void -psplash_fb_draw_text (PSplashFB *fb, - int x, - int y, - uint8 red, - uint8 green, - uint8 blue, - const PSplashFont *font, - const char *text) -{ - int h, w, k, n, cx, cy, dx, dy; - char *c = (char*)text; - wchar_t wc; - - n = strlen (text); - h = font->height; - dx = dy = 0; - - mbtowc (0, 0, 0); - for (; (k = mbtowc (&wc, c, n)) > 0; c += k, n -= k) - { - u_int32_t *glyph = NULL; - - if (*c == '\n') - { - dy += h; - dx = 0; - continue; - } - - w = psplash_font_glyph (font, wc, &glyph); - - if (glyph == NULL) - continue; - - for (cy = 0; cy < h; cy++) - { - u_int32_t g = *glyph++; - - for (cx = 0; cx < w; cx++) - { - if (g & 0x80000000) - psplash_plot_pixel(&fb->canvas, x+dx+cx, y+dy+cy, - red, green, blue); - g <<= 1; - } - } - - dx += w; - } -} - diff --git a/psplash-fb.h b/psplash-fb.h index 1eecb47..1b16bd5 100644 --- a/psplash-fb.h +++ b/psplash-fb.h @@ -40,22 +40,6 @@ psplash_fb_destroy (PSplashFB *fb); PSplashFB* psplash_fb_new (int angle, int fbdev_id); -void -psplash_fb_text_size (int *width, - int *height, - const PSplashFont *font, - const char *text); - -void -psplash_fb_draw_text (PSplashFB *fb, - int x, - int y, - uint8 red, - uint8 green, - uint8 blue, - const PSplashFont *font, - const char *text); - void psplash_fb_flip(PSplashFB *fb, int sync); diff --git a/psplash.c b/psplash.c index 2aeb583..1a5e543 100644 --- a/psplash.c +++ b/psplash.c @@ -41,7 +41,7 @@ psplash_draw_msg (PSplashFB *fb, const char *msg) { int w, h; - psplash_fb_text_size (&w, &h, &FONT_DEF, msg); + psplash_text_size(&w, &h, &FONT_DEF, msg); DBG("displaying '%s' %ix%i\n", msg, w, h); @@ -54,7 +54,7 @@ psplash_draw_msg (PSplashFB *fb, const char *msg) h, PSPLASH_BACKGROUND_COLOR); - psplash_fb_draw_text (fb, + psplash_draw_text(&fb->canvas, (fb->canvas.width-w)/2, SPLIT_LINE_POS(fb) - h, PSPLASH_TEXT_COLOR, From patchwork Mon Apr 25 07:59:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasyl Vavrychuk X-Patchwork-Id: 7083 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63915C49ED8 for ; Mon, 25 Apr 2022 19:26:13 +0000 (UTC) Received: from repostorp.tmes.trendmicro.eu (repostorp.tmes.trendmicro.eu [18.185.115.139]) by mx.groups.io with SMTP id smtpd.web12.26780.1650873627813712402 for ; Mon, 25 Apr 2022 01:00:28 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@opensynergy.com header.s=tm-dkim-20210503141657 header.b=FXVxwGey; spf=pass (domain: opensynergy.com, ip: 18.185.115.139, mailfrom: vasyl.vavrychuk@opensynergy.com) Received: from 104.47.17.104_.trendmicro.com (unknown [172.21.180.2]) by repostorp.tmes.trendmicro.eu (Postfix) with SMTP id BEECC10000304 for ; Mon, 25 Apr 2022 08:00:24 +0000 (UTC) X-TM-MAIL-RECEIVED-TIME: 1650873623.699000 X-TM-MAIL-UUID: cf09b989-2061-46f1-b097-019d70cb3191 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (unknown [104.47.17.104]) by repre01.tmes.trendmicro.eu (Trend Micro Email Security) with ESMTPS id AAD8F100010B4 for ; Mon, 25 Apr 2022 08:00:23 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CxCzfTJstBycfClmW1q0+5dTkbl9AH4nwGtTengT3ViV32ijtVOpu+Rs3Ar09OxKBiQHjJx+RR964akfU81h0A5uuCKN8IgMWRCfQLLdjiA04A7DChnQDE5qmjl89wyrOso5d3PZA9ZUmfsF6EUZnoCPlOT2rq5OZ0ie8YRCyOezgBnicBiFMlWIY3NyVIu0PhQNy0ZEOaLsVgZ4U3s3pwbTH4b4G6zLihr3xgiFjq/02kQl5RxRUnvunE+XABA+mvQRG9D2m5dd12t8ALcLp78yuZ6cMAzEo3svXPlnT+XOb0nDlIFOwFVkuovd5Cez/QNvKDERUhDE3MTgHp1FHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=07T6mAIQuK7KAOKIFjw1qwvvJ51W9GWI2xpI1hlnj6g=; b=KsG632fYJyDwOpF6bQNPaXlbz1OP/JYmBGONxNwgd4GuzodgVDbPP6HZplt5XKL7JcFc/b9Z2eoTL55pP849sLBPxB5vQjE3aZvUu0x04+OmfzleZgfSMZg7w65IdZhp5EVNcy2n/XcttcyKf9wMNOgr4XoA64yOYND/dMBDMy7Lfq+OR/qL4dL214VWKh4UdXqzrXOxOYNG24nx6fOyf9iIHLclWPfmTWGwEHaSVl6iNqyrApOwTgA/99HLIPMiHjhRIM4tuyo17D7kcRKe/mrZ+atkyT6p1d+kQ3rQKXTiBxFB7sJh2ZjKFSA8odEjlAN0cERz6w18aeY/cD9oJA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 217.66.60.4) smtp.rcpttodomain=lists.yoctoproject.org smtp.mailfrom=opensynergy.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=opensynergy.com; dkim=none (message not signed); arc=none X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 217.66.60.4) smtp.mailfrom=opensynergy.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=opensynergy.com; Received-SPF: Pass (protection.outlook.com: domain of opensynergy.com designates 217.66.60.4 as permitted sender) receiver=protection.outlook.com; client-ip=217.66.60.4; helo=SR-MAIL-03.open-synergy.com; From: Vasyl Vavrychuk To: yocto@lists.yoctoproject.org Cc: Vasyl Vavrychuk Subject: [psplash][RFC PATCH 08/14] psplash.c: Make psplash_draw_{msg,progress} independent of FB Date: Mon, 25 Apr 2022 10:59:48 +0300 Message-Id: <20220425075954.10427-9-vasyl.vavrychuk@opensynergy.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220425075954.10427-1-vasyl.vavrychuk@opensynergy.com> References: <20220425075954.10427-1-vasyl.vavrychuk@opensynergy.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 30847632-0cbc-4199-ca7d-08da2691a569 X-MS-TrafficTypeDiagnostic: DB7PR04MB4395:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: g0VG+vUTrbo6+7nGlWKbXLv+rHnfLRnC21rITgZxKqqlltljM0/BXFne0Il1mN4mXTDpygOVPt3j2KGXLzsiBFtg+HHuTon5/QQecuPQI0F19fpFkwGWKMxMYCLPF2CZaG4rn9g74O3zrR7eWhaHb8Y1G0o+ote0GBWJV/8c3gq+5cv/8gT0u8jRomwOWBo9hZ/O/lYivf+qVIzbO2lsOjLNceUVQbTWLvzlJD2hl8FFQqQtwCtDLF7jWIQwqy4Q7OQxYM5EBLBrK5JFTGSYe5nFe8XYWg4HCP56ZvJFZkmKno12tXGf1Td1kxPzZZkr4aaQ+FB9LbFjTnOwgdrvDC3qv5iOhjXawm0gljtmpUDLyb1j076klaS+ML7VmuzKHVlpr7tVatvkFTjclP5MZmV0ibDuw/b7NOYznPFdYTIbn62rfXgiGINlYDldrwIcnYS8b6n1V0o8oMMcjoTqrQ6s8l4awSENaaz5BoyJ6AxVZFr5yigJq0DafceAfCXYbdA8ovVr10aGEVt/ZhuYRgzLm9c090YbRw082jEf37ZYe4jmCwGBkq0AOrLIsM7Die4uW9FnRspfEEdy/ctwoYgKbM4yZn/h5zA8Le3KOueIRhbNox9ccQRgT8hG671SSxlgPxwXY/yOjW1XNBtHl0yDMzdVhD+z2eMKAGkRN463uq4j12FQxJfRNrPn/H3Z X-Forefront-Antispam-Report: CIP:217.66.60.4;CTRY:DE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SR-MAIL-03.open-synergy.com;PTR:mx1.opensynergy.com;CAT:NONE;SFS:(13230001)(376002)(346002)(396003)(39830400003)(136003)(36840700001)(46966006)(2906002)(81166007)(36756003)(82310400005)(5660300002)(40480700001)(70586007)(42186006)(6916009)(70206006)(316002)(508600001)(8676002)(26005)(36860700001)(86362001)(83380400001)(8936002)(44832011)(4326008)(186003)(336012)(47076005)(2616005)(1076003)(107886003);DIR:OUT;SFP:1102; X-OriginatorOrg: opensynergy.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2022 08:00:21.2852 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 30847632-0cbc-4199-ca7d-08da2691a569 X-MS-Exchange-CrossTenant-Id: 800fae25-9b1b-4edc-993d-c939c4e84a64 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=800fae25-9b1b-4edc-993d-c939c4e84a64;Ip=[217.66.60.4];Helo=[SR-MAIL-03.open-synergy.com] X-MS-Exchange-CrossTenant-AuthSource: AM6EUR05FT031.eop-eur05.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB4395 X-TM-AS-ERS: 104.47.17.104-0.0.0.0 X-TMASE-Version: StarCloud-1.3-8.8.1001-26854.006 X-TMASE-Result: 11-5.242400-4.000000 X-TMASE-MatchedRID: fG9GIPJoGIEv+0FNnM7lDQPZZctd3P4B1jd10P+8LE9dKWx22BOmiWL0 6liIG52auUxcEq68iwMVQaIxyJ2Ho/VACeiFsAcySs47mbT7SAT1q+x7zkhJWtxDe8KhkxJB1w6 ADg6BQG+igA0wY1tPCCYSZkru5yf1+4GoV6huZip+yskgwrfsC30tCKdnhB58FMkUvzgg/cWfop 0ytGwvXiq2rl3dzGQ1uzMYY7Xys2op1jeTZflVcthtQn0jOeJ+YsLtk+EV7nbefSnsJ/n5IA== X-TMASE-XGENCLOUD: 414fc9a4-160f-4eef-b731-2739e3b8dec5-0-0-200-0 X-TM-Deliver-Signature: 6609B2C84E511462625395F2A2FDBE33 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=opensynergy.com; s=TM-DKIM-20210503141657; t=1650873624; bh=/tE1/yq50GddQvOmFZRV7GVrkIc0b/F7caC/KEjg5EM=; l=5653; h=From:To:Date; b=FXVxwGey6oq86VQX5yMemZOSfgemh2NYPxAeW8Dqmjm2C8pGl8v2t1iz4PsMm5URs /KWxdhsnOB6crFfhrpCP/m38WKZfWmecMGFlHWjaQbPCpQruQh9vRaMAfLSJIBdvRZ 7Tyd51tHfxRhF6sdz6CBQ5Crzifz2Lm8KW9H1pcHozwGrGcWcgyQygUibrdYAtW6G6 ZC1P7Nb/kBcZIikmlmj2IdZuGe3sAfMxgSaooIDboYQqty7zmLnDy7jLHeeUdiM9lQ Klw4okuHMunSF9cM7b1r0KRAMVep4+O8RONxeWSLa1CAKK8IC5zH+kHJMe4XJjVTD4 KGNoAGbchBOHg== List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 25 Apr 2022 19:26:13 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto/message/56866 Signed-off-by: Vasyl Vavrychuk --- psplash.c | 64 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/psplash.c b/psplash.c index 1a5e543..c234d46 100644 --- a/psplash.c +++ b/psplash.c @@ -21,11 +21,11 @@ #endif #include FONT_HEADER -#define SPLIT_LINE_POS(fb) \ - ( (fb)->canvas.height \ - - (( PSPLASH_IMG_SPLIT_DENOMINATOR \ - - PSPLASH_IMG_SPLIT_NUMERATOR) \ - * (fb)->canvas.height / PSPLASH_IMG_SPLIT_DENOMINATOR) \ +#define SPLIT_LINE_POS(canvas) \ + ( (canvas)->height \ + - (( PSPLASH_IMG_SPLIT_DENOMINATOR \ + - PSPLASH_IMG_SPLIT_NUMERATOR) \ + * (canvas)->height / PSPLASH_IMG_SPLIT_DENOMINATOR) \ ) void @@ -37,7 +37,7 @@ psplash_exit (int UNUSED(signum)) } void -psplash_draw_msg (PSplashFB *fb, const char *msg) +psplash_draw_msg(PSplashCanvas *canvas, const char *msg) { int w, h; @@ -47,16 +47,16 @@ psplash_draw_msg (PSplashFB *fb, const char *msg) /* Clear */ - psplash_draw_rect(&fb->canvas, + psplash_draw_rect(canvas, 0, - SPLIT_LINE_POS(fb) - h, - fb->canvas.width, + SPLIT_LINE_POS(canvas) - h, + canvas->width, h, PSPLASH_BACKGROUND_COLOR); - psplash_draw_text(&fb->canvas, - (fb->canvas.width-w)/2, - SPLIT_LINE_POS(fb) - h, + psplash_draw_text(canvas, + (canvas->width-w)/2, + SPLIT_LINE_POS(canvas) - h, PSPLASH_TEXT_COLOR, &FONT_DEF, msg); @@ -64,32 +64,32 @@ psplash_draw_msg (PSplashFB *fb, const char *msg) #ifdef PSPLASH_SHOW_PROGRESS_BAR void -psplash_draw_progress (PSplashFB *fb, int value) +psplash_draw_progress(PSplashCanvas *canvas, int value) { int x, y, width, height, barwidth; /* 4 pix border */ - x = ((fb->canvas.width - BAR_IMG_WIDTH)/2) + 4 ; - y = SPLIT_LINE_POS(fb) + 4; + x = ((canvas->width - BAR_IMG_WIDTH)/2) + 4 ; + y = SPLIT_LINE_POS(canvas) + 4; width = BAR_IMG_WIDTH - 8; height = BAR_IMG_HEIGHT - 8; if (value > 0) { barwidth = (CLAMP(value,0,100) * width) / 100; - psplash_draw_rect(&fb->canvas, x + barwidth, y, + psplash_draw_rect(canvas, x + barwidth, y, width - barwidth, height, PSPLASH_BAR_BACKGROUND_COLOR); - psplash_draw_rect(&fb->canvas, x, y, barwidth, + psplash_draw_rect(canvas, x, y, barwidth, height, PSPLASH_BAR_COLOR); } else { barwidth = (CLAMP(-value,0,100) * width) / 100; - psplash_draw_rect(&fb->canvas, x, y, + psplash_draw_rect(canvas, x, y, width - barwidth, height, PSPLASH_BAR_BACKGROUND_COLOR); - psplash_draw_rect(&fb->canvas, x + width - barwidth, + psplash_draw_rect(canvas, x + width - barwidth, y, barwidth, height, PSPLASH_BAR_COLOR); } @@ -116,7 +116,7 @@ parse_command (PSplashFB *fb, char *string) char *arg = strtok(NULL, "\0"); if (arg) - psplash_draw_msg (fb, arg); + psplash_draw_msg(&fb->canvas, arg); } #ifdef PSPLASH_SHOW_PROGRESS_BAR else if (!strcmp(command,"PROGRESS")) @@ -124,7 +124,7 @@ parse_command (PSplashFB *fb, char *string) char *arg = strtok(NULL, "\0"); if (arg) - psplash_draw_progress (fb, atoi(arg)); + psplash_draw_progress(&fb->canvas, atoi(arg)); } #endif else if (!strcmp(command,"QUIT")) @@ -226,6 +226,7 @@ main (int argc, char** argv) char *rundir; int pipe_fd, i = 0, angle = 0, fbdev_id = 0, ret = 0; PSplashFB *fb; + PSplashCanvas *canvas; bool disable_console_switch = FALSE; signal(SIGHUP, psplash_exit); @@ -295,22 +296,23 @@ main (int argc, char** argv) ret = -1; goto fb_fail; } + canvas = &fb->canvas; #ifdef HAVE_SYSTEMD sd_notify(0, "READY=1"); #endif /* Clear the background with #ecece1 */ - psplash_draw_rect(&fb->canvas, 0, 0, fb->canvas.width, fb->canvas.height, + psplash_draw_rect(canvas, 0, 0, canvas->width, canvas->height, PSPLASH_BACKGROUND_COLOR); /* Draw the Poky logo */ - psplash_draw_image(&fb->canvas, - (fb->canvas.width - POKY_IMG_WIDTH)/2, + psplash_draw_image(canvas, + (canvas->width - POKY_IMG_WIDTH)/2, #if PSPLASH_IMG_FULLSCREEN - (fb->canvas.height - POKY_IMG_HEIGHT)/2, + (canvas->height - POKY_IMG_HEIGHT)/2, #else - (fb->canvas.height * PSPLASH_IMG_SPLIT_NUMERATOR + (canvas->height * PSPLASH_IMG_SPLIT_NUMERATOR / PSPLASH_IMG_SPLIT_DENOMINATOR - POKY_IMG_HEIGHT)/2, #endif POKY_IMG_WIDTH, @@ -321,20 +323,20 @@ main (int argc, char** argv) #ifdef PSPLASH_SHOW_PROGRESS_BAR /* Draw progress bar border */ - psplash_draw_image(&fb->canvas, - (fb->canvas.width - BAR_IMG_WIDTH)/2, - SPLIT_LINE_POS(fb), + psplash_draw_image(canvas, + (canvas->width - BAR_IMG_WIDTH)/2, + SPLIT_LINE_POS(canvas), BAR_IMG_WIDTH, BAR_IMG_HEIGHT, BAR_IMG_BYTES_PER_PIXEL, BAR_IMG_ROWSTRIDE, BAR_IMG_RLE_PIXEL_DATA); - psplash_draw_progress (fb, 0); + psplash_draw_progress(canvas, 0); #endif #ifdef PSPLASH_STARTUP_MSG - psplash_draw_msg (fb, PSPLASH_STARTUP_MSG); + psplash_draw_msg(canvas, PSPLASH_STARTUP_MSG); #endif /* Scene set so let's flip the buffers. */ From patchwork Mon Apr 25 07:59:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasyl Vavrychuk X-Patchwork-Id: 7092 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93EF8C54F65 for ; Mon, 25 Apr 2022 19:26:13 +0000 (UTC) Received: from repost01.tmes.trendmicro.eu (repost01.tmes.trendmicro.eu [18.185.115.23]) by mx.groups.io with SMTP id smtpd.web10.26704.1650873650796267774 for ; Mon, 25 Apr 2022 01:00:51 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@opensynergy.com header.s=tm-dkim-20210503141657 header.b=kvN4VhXa; spf=pass (domain: opensynergy.com, ip: 18.185.115.23, mailfrom: vasyl.vavrychuk@opensynergy.com) Received: from 104.47.18.111_.trendmicro.com (unknown [172.21.163.172]) by repost01.tmes.trendmicro.eu (Postfix) with SMTP id 7585B1000065A for ; Mon, 25 Apr 2022 08:00:49 +0000 (UTC) X-TM-MAIL-RECEIVED-TIME: 1650873627.931000 X-TM-MAIL-UUID: efa81cc7-dc89-4917-8f24-61339bc5f3d0 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (unknown [104.47.18.111]) by repre01.tmes.trendmicro.eu (Trend Micro Email Security) with ESMTPS id E36FC100029CE for ; Mon, 25 Apr 2022 08:00:27 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PrKlrDJpW5or4ZUTzGSVwP6iqa0dO/Zofv3tmdVQNJyLbjBJpzbJ5BaGKLNRBgcmvsyrzCE3id4g6SUkedLbxBT94POiA0WnuOicKthbnSGZQADb/1AkjkneGiFdaTNd3ADv78H77Ap4YR+g87GKHCDZyyQYTaTWmTt1X4YCjt2ehFuzxjWgzeTybuEQ6pfVoYbLWACR6mcFLSzNKfMWSNBwm3MXFsweuXMjBAxrhattbJvn5eS9pUg/0Zn6lo5yz2/gFZPiBYyBab0xQYV3umbz02cPJB1YhV5KunR9D+M6DF41k81QQhQh/kIq1CTE3Z/7HsxyiSZ7Rb6l4aH1AA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=s1u9CZn+pCL/M1Qsg0zIYrGjqV+CZASVcTITTXTcetY=; b=O2t7xBp2eVjNlKOnKSkmpkshT1V4U1LOaTapDizHx8fgmcU4MLVrdhEKFdNO3RUHRjqYfokqxrDT+dEqpvhlQueF4CoWsqAIPOc47vfqqDuy8fYfr+FwBhrpnp4w05+ziSqKcl3pgpsq4pcX6WayIoDUfp4ZnuSep7SEfPXvCu/bJtA1FM+lr2EVM1lJcJxY2ZrSBm7FCXBUvyveyAuEuNI2f67chb+ODYzk3AKVpRwsL6e/sshcR6yV1wDWUFMCobPAe5kI5afao0FC/Z8OvqNbT+a6kKyCeiNal5DnNQHAz0TvOFP+RcG/qChXbbfx3BmVkwYkZtLvw61qrLiVpw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 217.66.60.4) smtp.rcpttodomain=lists.yoctoproject.org smtp.mailfrom=opensynergy.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=opensynergy.com; dkim=none (message not signed); arc=none X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 217.66.60.4) smtp.mailfrom=opensynergy.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=opensynergy.com; Received-SPF: Pass (protection.outlook.com: domain of opensynergy.com designates 217.66.60.4 as permitted sender) receiver=protection.outlook.com; client-ip=217.66.60.4; helo=SR-MAIL-03.open-synergy.com; From: Vasyl Vavrychuk To: yocto@lists.yoctoproject.org Cc: Vasyl Vavrychuk Subject: [psplash][RFC PATCH 09/14] Rework flip as function pointer Date: Mon, 25 Apr 2022 10:59:49 +0300 Message-Id: <20220425075954.10427-10-vasyl.vavrychuk@opensynergy.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220425075954.10427-1-vasyl.vavrychuk@opensynergy.com> References: <20220425075954.10427-1-vasyl.vavrychuk@opensynergy.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 89e900c5-dccb-40e7-53f0-08da2691a5ad X-MS-TrafficTypeDiagnostic: VI1PR04MB3279:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: N1adde3vFz6+IWSwuJlW0d+A0HnbMBbOIaVNbTsDFxqiLHhxxcxI/1r8g/Kp+PXBq2vVp5YaO2JMO1yS2dQHmjqBrHcu4EiNo0XPiEL5hCBdtiQnRh9vM49nV7J73dQgeGpB47aIbcEbOf1JB6I9UAGcbMUlVsD3X7DcTfEvCGYbfn/aVPlR7Yd1inf4Ijkh8uzKXzagLT4LfVjdlILC73Rog08rqmwJPTl+Lcm0CGpceUrzn6UUnarFlsqzpjYDfbyFxu/rOXQQgmfcsr6hjJdnYNO8YUY/dAgOPrRZLNl7Ml7g7m59Cs6LWabcVKvuytwBAe2SJq4soRc9tjvwmZZqgS1t8S6PPsyXmU0yz0kBznSm/42lgdNqi4HQGWO3fDkIhkuchYEqdUaqS4fLQGZf44560KEK/3iQUE7ZTOXL7dbBwq+W3Eo6zXaPFD2LXSr/LA6g1M/hsBHwjEpc/vwRlY2q2U2M7gHfcAi2kM6z7bebAPcyZncCTKdm3CqsiVFqx17NOsvloeei/1HvCL7qzyfhshnwoJ1keTh7lr6GxXUPI2wurm36N78f8FQEs3IQUjRmE62AgrN2xZGs4e+va8vXib3/VBRiR3JyScFdg/k5WF1S6fNFkxggMcib1sFOFb49IQDFr5eGf0dHh1d23MRQipfbz2eifVgAsJedbq2VNmd9WjTSeGqRv/nb X-Forefront-Antispam-Report: CIP:217.66.60.4;CTRY:DE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SR-MAIL-03.open-synergy.com;PTR:mx1.opensynergy.com;CAT:NONE;SFS:(13230001)(136003)(396003)(376002)(346002)(39830400003)(46966006)(36840700001)(40480700001)(42186006)(508600001)(70206006)(86362001)(81166007)(6916009)(316002)(83380400001)(2906002)(107886003)(4326008)(8676002)(2616005)(36756003)(70586007)(1076003)(186003)(47076005)(336012)(5660300002)(8936002)(26005)(82310400005)(36860700001)(44832011);DIR:OUT;SFP:1102; X-OriginatorOrg: opensynergy.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2022 08:00:21.7278 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 89e900c5-dccb-40e7-53f0-08da2691a5ad X-MS-Exchange-CrossTenant-Id: 800fae25-9b1b-4edc-993d-c939c4e84a64 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=800fae25-9b1b-4edc-993d-c939c4e84a64;Ip=[217.66.60.4];Helo=[SR-MAIL-03.open-synergy.com] X-MS-Exchange-CrossTenant-AuthSource: VI1EUR05FT009.eop-eur05.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB3279 X-TM-AS-ERS: 104.47.18.111-0.0.0.0 X-TMASE-Version: StarCloud-1.3-8.8.1001-26854.006 X-TMASE-Result: 10--3.857500-4.000000 X-TMASE-MatchedRID: nFBGW9VXCz7iATtmJziXs7nHu4BcYSmtwTlc9CcHMZerwqxtE531VIPc XuILVCbaiRWGvcr6dQYgwsEf6dBaBax/TSRv9EiNDnkURiAlfT2ZIt4iAQN6P+2N+fLk/cblcRF tLs5mkQMPNxz2EvpSIOCK9EyBltlmrzydp5JZYFkMlstlDZ8gF0pO/ORUaZ3FmyiLZetSf8m2Ie O/ulJw0cFwgTvxipFajoczmuoPCq0/wimOYKcUHshLhSsiu1SSuFQx0ldRtJvoB2OOazjJIA9kB bbSZ9tr X-TMASE-XGENCLOUD: fcaebcf0-98d1-9165-98b0-a60e6b058e37-0-0-200-0 X-TM-Deliver-Signature: 30E0C57B5A8CF0A6CFE5AABB819EA0B1 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=opensynergy.com; s=TM-DKIM-20210503141657; t=1650873649; bh=WOloovGi4/mME8qjbNAlSsj+HvzRZPjB8tvH2Wo7f1s=; l=3529; h=From:To:Date; b=kvN4VhXaivZ92cQLOih/NeU+3o1xL9TTE3IebRD8NGlT16yAnADQSCHO6LcE3K31z +mA9UdWNaZIdPjBjlY2tBexK9X2Xoy4AoDHcZgWHK5f7fO2U8cwFok5fe9YuddF87j SgPjcUwGxCYN1hv0fBZ8b0t/u6bzh9k5vGEIbEOr4j9qP7UoeXsV76m06AjG/Io0Uy I1bcwzCOLVUPmXu4MXNiNDusQJdf5JEPy+xZjbZwtC73Z5VMFWNc8OSMWHnCDynDoH ZIBTcQtNJIDQof3VWM+9JM8fPxEd7fXvdeo9SmPowj+/Wpwmv27zs1vDlZkKs2SX5k FU+ZNGA0e8aUA== List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 25 Apr 2022 19:26:13 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto/message/56872 It allows making parse_command and psplash_main independent of FB. Signed-off-by: Vasyl Vavrychuk --- psplash-draw.h | 3 +++ psplash-fb.c | 8 +++++--- psplash-fb.h | 3 --- psplash.c | 16 ++++++++-------- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/psplash-draw.h b/psplash-draw.h index 44546b0..292ddd9 100644 --- a/psplash-draw.h +++ b/psplash-draw.h @@ -36,6 +36,9 @@ typedef struct PSplashCanvas int green_length; int blue_offset; int blue_length; + + void *priv; + void (*flip)(struct PSplashCanvas *canvas, int sync); } PSplashCanvas; diff --git a/psplash-fb.c b/psplash-fb.c index dd50a5a..d41c477 100644 --- a/psplash-fb.c +++ b/psplash-fb.c @@ -18,9 +18,10 @@ psplash_wait_for_vsync(PSplashFB *fb) fprintf(stderr, "Error, FB vsync ioctl [%d]\n", err); } -void -psplash_fb_flip(PSplashFB *fb, int sync) +static void +psplash_fb_flip(PSplashCanvas *canvas, int sync) { + PSplashFB *fb = canvas->priv; char *tmp; if (fb->double_buffering) { @@ -154,7 +155,8 @@ psplash_fb_new (int angle, int fbdev_id) } memset (fb, 0, sizeof(PSplashFB)); - + fb->canvas.priv = fb; + fb->canvas.flip = psplash_fb_flip; fb->fd = -1; if ((fb->fd = open (fbdev, O_RDWR)) < 0) diff --git a/psplash-fb.h b/psplash-fb.h index 1b16bd5..979d23a 100644 --- a/psplash-fb.h +++ b/psplash-fb.h @@ -40,7 +40,4 @@ psplash_fb_destroy (PSplashFB *fb); PSplashFB* psplash_fb_new (int angle, int fbdev_id); -void -psplash_fb_flip(PSplashFB *fb, int sync); - #endif diff --git a/psplash.c b/psplash.c index c234d46..036dfb1 100644 --- a/psplash.c +++ b/psplash.c @@ -100,7 +100,7 @@ psplash_draw_progress(PSplashCanvas *canvas, int value) #endif /* PSPLASH_SHOW_PROGRESS_BAR */ static int -parse_command (PSplashFB *fb, char *string) +parse_command(PSplashCanvas *canvas, char *string) { char *command; @@ -116,7 +116,7 @@ parse_command (PSplashFB *fb, char *string) char *arg = strtok(NULL, "\0"); if (arg) - psplash_draw_msg(&fb->canvas, arg); + psplash_draw_msg(canvas, arg); } #ifdef PSPLASH_SHOW_PROGRESS_BAR else if (!strcmp(command,"PROGRESS")) @@ -124,7 +124,7 @@ parse_command (PSplashFB *fb, char *string) char *arg = strtok(NULL, "\0"); if (arg) - psplash_draw_progress(&fb->canvas, atoi(arg)); + psplash_draw_progress(canvas, atoi(arg)); } #endif else if (!strcmp(command,"QUIT")) @@ -132,12 +132,12 @@ parse_command (PSplashFB *fb, char *string) return 1; } - psplash_fb_flip(fb, 0); + canvas->flip(canvas, 0); return 0; } void -psplash_main (PSplashFB *fb, int pipe_fd, int timeout) +psplash_main(PSplashCanvas *canvas, int pipe_fd, int timeout) { int err; ssize_t length = 0; @@ -200,7 +200,7 @@ psplash_main (PSplashFB *fb, int pipe_fd, int timeout) continue; } - if (parse_command(fb, cmd)) + if (parse_command(canvas, cmd)) return; length -= cmdlen; @@ -345,9 +345,9 @@ main (int argc, char** argv) * text and progress bar change which overwrite the specific areas with every * update. */ - psplash_fb_flip(fb, 1); + canvas->flip(canvas, 1); - psplash_main (fb, pipe_fd, 0); + psplash_main(canvas, pipe_fd, 0); psplash_fb_destroy (fb); From patchwork Mon Apr 25 07:59:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasyl Vavrychuk X-Patchwork-Id: 7094 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86384C54F3E for ; Mon, 25 Apr 2022 19:26:13 +0000 (UTC) Received: from repost01.tmes.trendmicro.eu (repost01.tmes.trendmicro.eu [18.185.115.5]) by mx.groups.io with SMTP id smtpd.web09.26991.1650873647995482624 for ; Mon, 25 Apr 2022 01:00:48 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@opensynergy.com header.s=tm-dkim-20210503141657 header.b=wpMvAbLN; spf=pass (domain: opensynergy.com, ip: 18.185.115.5, mailfrom: vasyl.vavrychuk@opensynergy.com) Received: from 104.47.2.51_.trendmicro.com (unknown [172.21.163.172]) by repost01.tmes.trendmicro.eu (Postfix) with SMTP id 707D9100022E1 for ; Mon, 25 Apr 2022 08:00:46 +0000 (UTC) X-TM-MAIL-RECEIVED-TIME: 1650873626.373000 X-TM-MAIL-UUID: f3f5cc31-7339-428e-b8d6-c136d418ab96 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (unknown [104.47.2.51]) by repre01.tmes.trendmicro.eu (Trend Micro Email Security) with ESMTPS id 5B5F510003741 for ; Mon, 25 Apr 2022 08:00:26 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AR2FRaNdWUcez2lN6YhxOIo5o8hcw+o0IstIqs++K4e/TuwUqjpJL8oidfb6otZr/XJzmMvpH9mNAtabgvDPSXBUtMCu0jv/wK4yNbAzax9rWD2cEYFRWIY05eEWSM6tDMrvRS2+jjig7Y9jP3O8moJl0vO0wQFFyBW5vitPq9U9l5O93FzaEJGHiRQoxjw07Su5GIl07LsDb1BapbyfWMol54SZvuZL503is1Tp9Ubnqf0srsNQv3sPFJZqargDBuqLKSIsS15z8nMaaODqhwL3mCCocHR6Q3wzt8ShR7ijIRJlVZ0p/UED5VlgSlyXQLtDnzdwKNn/yvrpDO1kFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=cw/pCck7whk3Si1UTHSKbyGbfs6yXnKUyvBcOuj0PMo=; b=VBm4L7tUakdEtR8n+P7jd5dgp+UkB65kbMdv+Xx+X87If7G77xpFuDFrVlQLJim23lQr0Zk1Qf8/RAQjIdVdD7Sc+95vZCwFFoeejhRrjhWpReKKbzkTaPeJQPhsXn9Yj8WPWjfuvOE+fS2Bpb/CjDm25kz1aj7lM8qsE2o51eEo7GsfHAfNjX0rzatG+rh5wTk/JLt59HLGcfsF9iUAfmuTqS4XcOfSHLztNOx48zKQ7imD4T/LnBIitBp8+sxP95kCqOWUe7vqFi7gGdMh8k2eCeGAWFELhH5YfZDU91K75eggjnj4tHZk5RD3JarYy+QqF2My3bjAf4W4baxgvQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=temperror (sender ip is 217.66.60.4) smtp.rcpttodomain=lists.yoctoproject.org smtp.mailfrom=opensynergy.com; dmarc=temperror action=none header.from=opensynergy.com; dkim=none (message not signed); arc=none X-MS-Exchange-Authentication-Results: spf=temperror (sender IP is 217.66.60.4) smtp.mailfrom=opensynergy.com; dkim=none (message not signed) header.d=none;dmarc=temperror action=none header.from=opensynergy.com; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of opensynergy.com: DNS Timeout) From: Vasyl Vavrychuk To: yocto@lists.yoctoproject.org Cc: Vasyl Vavrychuk Subject: [psplash][RFC PATCH 10/14] Import drm-howto modeset.c as psplash-drm.c Date: Mon, 25 Apr 2022 10:59:50 +0300 Message-Id: <20220425075954.10427-11-vasyl.vavrychuk@opensynergy.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220425075954.10427-1-vasyl.vavrychuk@opensynergy.com> References: <20220425075954.10427-1-vasyl.vavrychuk@opensynergy.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a810c750-14c4-432c-3515-08da2691a5d2 X-MS-TrafficTypeDiagnostic: AM7PR04MB7144:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yzYm+Q9XNn/knjd1okBOimo8gclQF+8T3IU/JrkXUVBzL2EemYv44mxBDPdMutppfZB+20UtK42qdGS8gAWSumKt+xRiPrDSaIdpW0aroGQcoJfB2r+zDWUPLAdUup5vo+iyxhK/Ylr413mwiq045NAwWMQhBNR3qp8J8Xe7lMtLOoPqY4T28fRhbOxXTEFnQx9xwXrjrt7NgVY+cZ/R1KqDg1sqtCku53Tx8eREQH3iUmss2Dx7xKnbF0ziRp3rQLZMPWYZgyiX3Sw/sl147CJZzoyYBWVV4wDEVMFwItU7GuSpGgh2EpmKnQzyJNfmyok0M+35riSAWBnrMc7fh3AdoMM1tiECmIWa76bCOTmViN6S4HTgFL/+4RbR9IYdpc8PddhjASyPteXfMUHOet1vrNj2re4D5E6sXOIWylASpJ7ghbtG/z3/V6sXepTdpj/HwxMj6W9k1Nt8uN+/Lqe5nt48t/uz7yqA4aNHyXsod3hGB82AYH/4OQfeb5VnjJNTKBeaG4rhUDDPUoKmdKKWJc26GmqlTCX8zZkvJv3v0nlAOmcn4qG7F/QkNP7d8tuoI3sj1Rz07bb+qQ1yjqHSq+WEWp2oYUPdC+vGd+bHGre87lS1qgQHkk8Ny5JRYAJCHOtT+SJHajbYE/N1pj7ncREVCQ+s+u+LwUFNj89s/Air2Bf5Go+qmPdDE42z8ChhyCyQY0e6mzjzH0be1VhGJqaKCNEpk6G8QazRjaNADtFLZJWkgSCUgHO9jZPlxKIWo6z24qSbA72OCq9qdWQtMDnz+UpdEq2MCY4e+dMhyFkQSJdDFhXSwFPGNclBxcq4u+yN0LGtPVY1pCJYPA== X-Forefront-Antispam-Report: CIP:217.66.60.4;CTRY:DE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SR-MAIL-03.open-synergy.com;PTR:mx1.opensynergy.com;CAT:NONE;SFS:(13230001)(346002)(136003)(396003)(376002)(39830400003)(36840700001)(46966006)(508600001)(86362001)(2616005)(8676002)(26005)(4326008)(966005)(316002)(42186006)(40480700001)(6916009)(70206006)(81166007)(70586007)(82310400005)(47076005)(19273905006)(336012)(30864003)(5660300002)(8936002)(63370400001)(63350400001)(36756003)(83380400001)(107886003)(1076003)(186003)(2906002)(44832011)(36860700001)(563064011);DIR:OUT;SFP:1102; X-OriginatorOrg: opensynergy.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2022 08:00:21.9695 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a810c750-14c4-432c-3515-08da2691a5d2 X-MS-Exchange-CrossTenant-Id: 800fae25-9b1b-4edc-993d-c939c4e84a64 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=800fae25-9b1b-4edc-993d-c939c4e84a64;Ip=[217.66.60.4];Helo=[SR-MAIL-03.open-synergy.com] X-MS-Exchange-CrossTenant-AuthSource: AM6EUR05FT047.eop-eur05.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR04MB7144 X-TM-AS-ERS: 104.47.2.51-0.0.0.0 X-TMASE-Version: StarCloud-1.3-8.8.1001-26854.006 X-TMASE-Result: 10--25.997900-4.000000 X-TMASE-MatchedRID: IgNyDWy1nLJhaj10i6TXQMYv//yaWh0DP8UQejhp29q8j0eQ+IUAHQSD CUdk18Wif146W0iUu2tMCgkc3/BmTUwYXRRr2ymn2Sa33ZGXWdaBiLDUCsch28fASe7knCtthjs M6fjcAyn1YRrloPf+Jo3gkRYeMdM+O4lAcKQRwo3wlvzzUUaf2aIazKtJxIUHRLQWlsj7XhPHee xQAHDXfEZrarpjLj2L7ySOi2zbTPwK011Ivs0zFBqkhv3OdF4DSLyuC617NWmcpGufbGiAqCdBl ANff8yfkD7dBt4dE2nbhCyicp/JyBkdCXR28QKxcCpWIzs12NWn9jE2Rk+acqkUwB3MABAny7d+ 7uYYRNm+zvmBxjl7LpifsYTYhe3oVZsjdPpr5NiYh7QjWI3JDPUORLBtNVve33Nl3elSfso6WzX m6eJNYNg76o9q9XdftqD63GOAwvtVlMCAFPVZHi0x8J2DopENgesVjcAB/Vvl90JVB3jyCuPhs1 7991vR3yKJ3jqLmA9YQP62QpRT7Iu21C7tun2gxrDvUMltogTnpmIrKZRxTrEoPl3jAkZdNE6mR LCupPicvGVeHmdfY5g8Up3LLwc2VPVUF2N3LyNv+ggm5QAi4ReK/B+WKxKsS3LxyJ8YfRQHjCTI F43I/czZXLR+atz9IBNGx6D5dgIOiGVwjkjOUIdlc1JaOB1TCCo+lsDuynXW2YYHslT0I1XKp+s scaSS1eKt+ktDRM90oU8EHuLaxh2FWI13Ey90kYD8wAZKsSDjLrHqvAiSy5F2kRRKjUQ9en4hsi SLu62smEouX0eLAkXHf81qWGNmzK+5MIDvDOV+yskgwrfsCyH5xd1Wn9PCmyiLZetSf8lRN1j+Z 19Ne0kpbiYOUmwx33fj+sMArfMaMUyeC0staEkVAPr0TXS8 X-TMASE-XGENCLOUD: 5a135cd8-d730-4972-b9ba-d86a34aab610-0-0-200-0 X-TM-Deliver-Signature: 5F80333085747B7FB573FCA63FD99CE6 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=opensynergy.com; s=TM-DKIM-20210503141657; t=1650873646; bh=9DRlDJ+eByMajORjoIDK2K/A22pTID7xPiFm+0ddhfs=; l=26714; h=From:To:Date; b=wpMvAbLNuM+aVhlFE3GFpmW6RD9Zp3Y47yKxmANMMVUYep0VynqDg6pE3FyD6sHtx 8L6jmP90WmQ6mgVmsDXc8lHhTZtbMfXFdI5lxRORyPBCigGIX7DdHl02ThxYfxiEhI 32qA9WfQtSY11wiR0MLW2v9paPLs66IFFGy7CZJF7g11KVVaKijSjW/D0Y4OyM2mBR CA0+wRD8w8meTsxgaKsC3WyfTCTIhCvF/Yw1ojVtmhsFyXDcK6tdypGP1PcIQL0MUq 5H4LpyiTL8BRrVM287q+X5Lt6WeUHt7gHxhfgVZOYN1SLfPi3Zv/TYYL8Tm4GJtifM dBBgCQ1K3ffDg== List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 25 Apr 2022 19:26:13 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto/message/56870 Imported as is from repo: https://github.com/dvdhrm/docs.git branch: master commit: fc5c63f path: drm-howto/modeset.c Signed-off-by: Vasyl Vavrychuk --- psplash-drm.c | 735 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 735 insertions(+) create mode 100644 psplash-drm.c diff --git a/psplash-drm.c b/psplash-drm.c new file mode 100644 index 0000000..c9a9f5c --- /dev/null +++ b/psplash-drm.c @@ -0,0 +1,735 @@ +/* + * modeset - DRM Modesetting Example + * + * Written 2012 by David Rheinsberg + * Dedicated to the Public Domain. + */ + +/* + * DRM Modesetting Howto + * This document describes the DRM modesetting API. Before we can use the DRM + * API, we have to include xf86drm.h and xf86drmMode.h. Both are provided by + * libdrm which every major distribution ships by default. It has no other + * dependencies and is pretty small. + * + * Please ignore all forward-declarations of functions which are used later. I + * reordered the functions so you can read this document from top to bottom. If + * you reimplement it, you would probably reorder the functions to avoid all the + * nasty forward declarations. + * + * For easier reading, we ignore all memory-allocation errors of malloc() and + * friends here. However, we try to correctly handle all other kinds of errors + * that may occur. + * + * All functions and global variables are prefixed with "modeset_*" in this + * file. So it should be clear whether a function is a local helper or if it is + * provided by some external library. + */ + +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct modeset_dev; +static int modeset_find_crtc(int fd, drmModeRes *res, drmModeConnector *conn, + struct modeset_dev *dev); +static int modeset_create_fb(int fd, struct modeset_dev *dev); +static int modeset_setup_dev(int fd, drmModeRes *res, drmModeConnector *conn, + struct modeset_dev *dev); +static int modeset_open(int *out, const char *node); +static int modeset_prepare(int fd); +static void modeset_draw(void); +static void modeset_cleanup(int fd); + +/* + * When the linux kernel detects a graphics-card on your machine, it loads the + * correct device driver (located in kernel-tree at ./drivers/gpu/drm/) and + * provides two character-devices to control it. Udev (or whatever hotplugging + * application you use) will create them as: + * /dev/dri/card0 + * /dev/dri/controlID64 + * We only need the first one. You can hard-code this path into your application + * like we do here, but it is recommended to use libudev with real hotplugging + * and multi-seat support. However, this is beyond the scope of this document. + * Also note that if you have multiple graphics-cards, there may also be + * /dev/dri/card1, /dev/dri/card2, ... + * + * We simply use /dev/dri/card0 here but the user can specify another path on + * the command line. + * + * modeset_open(out, node): This small helper function opens the DRM device + * which is given as @node. The new fd is stored in @out on success. On failure, + * a negative error code is returned. + * After opening the file, we also check for the DRM_CAP_DUMB_BUFFER capability. + * If the driver supports this capability, we can create simple memory-mapped + * buffers without any driver-dependent code. As we want to avoid any radeon, + * nvidia, intel, etc. specific code, we depend on DUMB_BUFFERs here. + */ + +static int modeset_open(int *out, const char *node) +{ + int fd, ret; + uint64_t has_dumb; + + fd = open(node, O_RDWR | O_CLOEXEC); + if (fd < 0) { + ret = -errno; + fprintf(stderr, "cannot open '%s': %m\n", node); + return ret; + } + + if (drmGetCap(fd, DRM_CAP_DUMB_BUFFER, &has_dumb) < 0 || + !has_dumb) { + fprintf(stderr, "drm device '%s' does not support dumb buffers\n", + node); + close(fd); + return -EOPNOTSUPP; + } + + *out = fd; + return 0; +} + +/* + * As a next step we need to find our available display devices. libdrm provides + * a drmModeRes structure that contains all the needed information. We can + * retrieve it via drmModeGetResources(fd) and free it via + * drmModeFreeResources(res) again. + * + * A physical connector on your graphics card is called a "connector". You can + * plug a monitor into it and control what is displayed. We are definitely + * interested in what connectors are currently used, so we simply iterate + * through the list of connectors and try to display a test-picture on each + * available monitor. + * However, this isn't as easy as it sounds. First, we need to check whether the + * connector is actually used (a monitor is plugged in and turned on). Then we + * need to find a CRTC that can control this connector. CRTCs are described + * later on. After that we create a framebuffer object. If we have all this, we + * can mmap() the framebuffer and draw a test-picture into it. Then we can tell + * the DRM device to show the framebuffer on the given CRTC with the selected + * connector. + * + * As we want to draw moving pictures on the framebuffer, we actually have to + * remember all these settings. Therefore, we create one "struct modeset_dev" + * object for each connector+crtc+framebuffer pair that we successfully + * initialized and push it into the global device-list. + * + * Each field of this structure is described when it is first used. But as a + * summary: + * "struct modeset_dev" contains: { + * - @next: points to the next device in the single-linked list + * + * - @width: width of our buffer object + * - @height: height of our buffer object + * - @stride: stride value of our buffer object + * - @size: size of the memory mapped buffer + * - @handle: a DRM handle to the buffer object that we can draw into + * - @map: pointer to the memory mapped buffer + * + * - @mode: the display mode that we want to use + * - @fb: a framebuffer handle with our buffer object as scanout buffer + * - @conn: the connector ID that we want to use with this buffer + * - @crtc: the crtc ID that we want to use with this connector + * - @saved_crtc: the configuration of the crtc before we changed it. We use it + * so we can restore the same mode when we exit. + * } + */ + +struct modeset_dev { + struct modeset_dev *next; + + uint32_t width; + uint32_t height; + uint32_t stride; + uint32_t size; + uint32_t handle; + uint8_t *map; + + drmModeModeInfo mode; + uint32_t fb; + uint32_t conn; + uint32_t crtc; + drmModeCrtc *saved_crtc; +}; + +static struct modeset_dev *modeset_list = NULL; + +/* + * So as next step we need to actually prepare all connectors that we find. We + * do this in this little helper function: + * + * modeset_prepare(fd): This helper function takes the DRM fd as argument and + * then simply retrieves the resource-info from the device. It then iterates + * through all connectors and calls other helper functions to initialize this + * connector (described later on). + * If the initialization was successful, we simply add this object as new device + * into the global modeset device list. + * + * The resource-structure contains a list of all connector-IDs. We use the + * helper function drmModeGetConnector() to retrieve more information on each + * connector. After we are done with it, we free it again with + * drmModeFreeConnector(). + * Our helper modeset_setup_dev() returns -ENOENT if the connector is currently + * unused and no monitor is plugged in. So we can ignore this connector. + */ + +static int modeset_prepare(int fd) +{ + drmModeRes *res; + drmModeConnector *conn; + unsigned int i; + struct modeset_dev *dev; + int ret; + + /* retrieve resources */ + res = drmModeGetResources(fd); + if (!res) { + fprintf(stderr, "cannot retrieve DRM resources (%d): %m\n", + errno); + return -errno; + } + + /* iterate all connectors */ + for (i = 0; i < res->count_connectors; ++i) { + /* get information for each connector */ + conn = drmModeGetConnector(fd, res->connectors[i]); + if (!conn) { + fprintf(stderr, "cannot retrieve DRM connector %u:%u (%d): %m\n", + i, res->connectors[i], errno); + continue; + } + + /* create a device structure */ + dev = malloc(sizeof(*dev)); + memset(dev, 0, sizeof(*dev)); + dev->conn = conn->connector_id; + + /* call helper function to prepare this connector */ + ret = modeset_setup_dev(fd, res, conn, dev); + if (ret) { + if (ret != -ENOENT) { + errno = -ret; + fprintf(stderr, "cannot setup device for connector %u:%u (%d): %m\n", + i, res->connectors[i], errno); + } + free(dev); + drmModeFreeConnector(conn); + continue; + } + + /* free connector data and link device into global list */ + drmModeFreeConnector(conn); + dev->next = modeset_list; + modeset_list = dev; + } + + /* free resources again */ + drmModeFreeResources(res); + return 0; +} + +/* + * Now we dig deeper into setting up a single connector. As described earlier, + * we need to check several things first: + * * If the connector is currently unused, that is, no monitor is plugged in, + * then we can ignore it. + * * We have to find a suitable resolution and refresh-rate. All this is + * available in drmModeModeInfo structures saved for each crtc. We simply + * use the first mode that is available. This is always the mode with the + * highest resolution. + * A more sophisticated mode-selection should be done in real applications, + * though. + * * Then we need to find an CRTC that can drive this connector. A CRTC is an + * internal resource of each graphics-card. The number of CRTCs controls how + * many connectors can be controlled indepedently. That is, a graphics-cards + * may have more connectors than CRTCs, which means, not all monitors can be + * controlled independently. + * There is actually the possibility to control multiple connectors via a + * single CRTC if the monitors should display the same content. However, we + * do not make use of this here. + * So think of connectors as pipelines to the connected monitors and the + * CRTCs are the controllers that manage which data goes to which pipeline. + * If there are more pipelines than CRTCs, then we cannot control all of + * them at the same time. + * * We need to create a framebuffer for this connector. A framebuffer is a + * memory buffer that we can write XRGB32 data into. So we use this to + * render our graphics and then the CRTC can scan-out this data from the + * framebuffer onto the monitor. + */ + +static int modeset_setup_dev(int fd, drmModeRes *res, drmModeConnector *conn, + struct modeset_dev *dev) +{ + int ret; + + /* check if a monitor is connected */ + if (conn->connection != DRM_MODE_CONNECTED) { + fprintf(stderr, "ignoring unused connector %u\n", + conn->connector_id); + return -ENOENT; + } + + /* check if there is at least one valid mode */ + if (conn->count_modes == 0) { + fprintf(stderr, "no valid mode for connector %u\n", + conn->connector_id); + return -EFAULT; + } + + /* copy the mode information into our device structure */ + memcpy(&dev->mode, &conn->modes[0], sizeof(dev->mode)); + dev->width = conn->modes[0].hdisplay; + dev->height = conn->modes[0].vdisplay; + fprintf(stderr, "mode for connector %u is %ux%u\n", + conn->connector_id, dev->width, dev->height); + + /* find a crtc for this connector */ + ret = modeset_find_crtc(fd, res, conn, dev); + if (ret) { + fprintf(stderr, "no valid crtc for connector %u\n", + conn->connector_id); + return ret; + } + + /* create a framebuffer for this CRTC */ + ret = modeset_create_fb(fd, dev); + if (ret) { + fprintf(stderr, "cannot create framebuffer for connector %u\n", + conn->connector_id); + return ret; + } + + return 0; +} + +/* + * modeset_find_crtc(fd, res, conn, dev): This small helper tries to find a + * suitable CRTC for the given connector. We have actually have to introduce one + * more DRM object to make this more clear: Encoders. + * Encoders help the CRTC to convert data from a framebuffer into the right + * format that can be used for the chosen connector. We do not have to + * understand any more of these conversions to make use of it. However, you must + * know that each connector has a limited list of encoders that it can use. And + * each encoder can only work with a limited list of CRTCs. So what we do is + * trying each encoder that is available and looking for a CRTC that this + * encoder can work with. If we find the first working combination, we are happy + * and write it into the @dev structure. + * But before iterating all available encoders, we first try the currently + * active encoder+crtc on a connector to avoid a full modeset. + * + * However, before we can use a CRTC we must make sure that no other device, + * that we setup previously, is already using this CRTC. Remember, we can only + * drive one connector per CRTC! So we simply iterate through the "modeset_list" + * of previously setup devices and check that this CRTC wasn't used before. + * Otherwise, we continue with the next CRTC/Encoder combination. + */ + +static int modeset_find_crtc(int fd, drmModeRes *res, drmModeConnector *conn, + struct modeset_dev *dev) +{ + drmModeEncoder *enc; + unsigned int i, j; + int32_t crtc; + struct modeset_dev *iter; + + /* first try the currently conected encoder+crtc */ + if (conn->encoder_id) + enc = drmModeGetEncoder(fd, conn->encoder_id); + else + enc = NULL; + + if (enc) { + if (enc->crtc_id) { + crtc = enc->crtc_id; + for (iter = modeset_list; iter; iter = iter->next) { + if (iter->crtc == crtc) { + crtc = -1; + break; + } + } + + if (crtc >= 0) { + drmModeFreeEncoder(enc); + dev->crtc = crtc; + return 0; + } + } + + drmModeFreeEncoder(enc); + } + + /* If the connector is not currently bound to an encoder or if the + * encoder+crtc is already used by another connector (actually unlikely + * but lets be safe), iterate all other available encoders to find a + * matching CRTC. */ + for (i = 0; i < conn->count_encoders; ++i) { + enc = drmModeGetEncoder(fd, conn->encoders[i]); + if (!enc) { + fprintf(stderr, "cannot retrieve encoder %u:%u (%d): %m\n", + i, conn->encoders[i], errno); + continue; + } + + /* iterate all global CRTCs */ + for (j = 0; j < res->count_crtcs; ++j) { + /* check whether this CRTC works with the encoder */ + if (!(enc->possible_crtcs & (1 << j))) + continue; + + /* check that no other device already uses this CRTC */ + crtc = res->crtcs[j]; + for (iter = modeset_list; iter; iter = iter->next) { + if (iter->crtc == crtc) { + crtc = -1; + break; + } + } + + /* we have found a CRTC, so save it and return */ + if (crtc >= 0) { + drmModeFreeEncoder(enc); + dev->crtc = crtc; + return 0; + } + } + + drmModeFreeEncoder(enc); + } + + fprintf(stderr, "cannot find suitable CRTC for connector %u\n", + conn->connector_id); + return -ENOENT; +} + +/* + * modeset_create_fb(fd, dev): After we have found a crtc+connector+mode + * combination, we need to actually create a suitable framebuffer that we can + * use with it. There are actually two ways to do that: + * * We can create a so called "dumb buffer". This is a buffer that we can + * memory-map via mmap() and every driver supports this. We can use it for + * unaccelerated software rendering on the CPU. + * * We can use libgbm to create buffers available for hardware-acceleration. + * libgbm is an abstraction layer that creates these buffers for each + * available DRM driver. As there is no generic API for this, each driver + * provides its own way to create these buffers. + * We can then use such buffers to create OpenGL contexts with the mesa3D + * library. + * We use the first solution here as it is much simpler and doesn't require any + * external libraries. However, if you want to use hardware-acceleration via + * OpenGL, it is actually pretty easy to create such buffers with libgbm and + * libEGL. But this is beyond the scope of this document. + * + * So what we do is requesting a new dumb-buffer from the driver. We specify the + * same size as the current mode that we selected for the connector. + * Then we request the driver to prepare this buffer for memory mapping. After + * that we perform the actual mmap() call. So we can now access the framebuffer + * memory directly via the dev->map memory map. + */ + +static int modeset_create_fb(int fd, struct modeset_dev *dev) +{ + struct drm_mode_create_dumb creq; + struct drm_mode_destroy_dumb dreq; + struct drm_mode_map_dumb mreq; + int ret; + + /* create dumb buffer */ + memset(&creq, 0, sizeof(creq)); + creq.width = dev->width; + creq.height = dev->height; + creq.bpp = 32; + ret = drmIoctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &creq); + if (ret < 0) { + fprintf(stderr, "cannot create dumb buffer (%d): %m\n", + errno); + return -errno; + } + dev->stride = creq.pitch; + dev->size = creq.size; + dev->handle = creq.handle; + + /* create framebuffer object for the dumb-buffer */ + ret = drmModeAddFB(fd, dev->width, dev->height, 24, 32, dev->stride, + dev->handle, &dev->fb); + if (ret) { + fprintf(stderr, "cannot create framebuffer (%d): %m\n", + errno); + ret = -errno; + goto err_destroy; + } + + /* prepare buffer for memory mapping */ + memset(&mreq, 0, sizeof(mreq)); + mreq.handle = dev->handle; + ret = drmIoctl(fd, DRM_IOCTL_MODE_MAP_DUMB, &mreq); + if (ret) { + fprintf(stderr, "cannot map dumb buffer (%d): %m\n", + errno); + ret = -errno; + goto err_fb; + } + + /* perform actual memory mapping */ + dev->map = mmap(0, dev->size, PROT_READ | PROT_WRITE, MAP_SHARED, + fd, mreq.offset); + if (dev->map == MAP_FAILED) { + fprintf(stderr, "cannot mmap dumb buffer (%d): %m\n", + errno); + ret = -errno; + goto err_fb; + } + + /* clear the framebuffer to 0 */ + memset(dev->map, 0, dev->size); + + return 0; + +err_fb: + drmModeRmFB(fd, dev->fb); +err_destroy: + memset(&dreq, 0, sizeof(dreq)); + dreq.handle = dev->handle; + drmIoctl(fd, DRM_IOCTL_MODE_DESTROY_DUMB, &dreq); + return ret; +} + +/* + * Finally! We have a connector with a suitable CRTC. We know which mode we want + * to use and we have a framebuffer of the correct size that we can write to. + * There is nothing special left to do. We only have to program the CRTC to + * connect each new framebuffer to each selected connector for each combination + * that we saved in the global modeset_list. + * This is done with a call to drmModeSetCrtc(). + * + * So we are ready for our main() function. First we check whether the user + * specified a DRM device on the command line, otherwise we use the default + * /dev/dri/card0. Then we open the device via modeset_open(). modeset_prepare() + * prepares all connectors and we can loop over "modeset_list" and call + * drmModeSetCrtc() on every CRTC/connector combination. + * + * But printing empty black pages is boring so we have another helper function + * modeset_draw() that draws some colors into the framebuffer for 5 seconds and + * then returns. And then we have all the cleanup functions which correctly free + * all devices again after we used them. All these functions are described below + * the main() function. + * + * As a side note: drmModeSetCrtc() actually takes a list of connectors that we + * want to control with this CRTC. We pass only one connector, though. As + * explained earlier, if we used multiple connectors, then all connectors would + * have the same controlling framebuffer so the output would be cloned. This is + * most often not what you want so we avoid explaining this feature here. + * Furthermore, all connectors will have to run with the same mode, which is + * also often not guaranteed. So instead, we only use one connector per CRTC. + * + * Before calling drmModeSetCrtc() we also save the current CRTC configuration. + * This is used in modeset_cleanup() to restore the CRTC to the same mode as was + * before we changed it. + * If we don't do this, the screen will stay blank after we exit until another + * application performs modesetting itself. + */ + +int main(int argc, char **argv) +{ + int ret, fd; + const char *card; + struct modeset_dev *iter; + + /* check which DRM device to open */ + if (argc > 1) + card = argv[1]; + else + card = "/dev/dri/card0"; + + fprintf(stderr, "using card '%s'\n", card); + + /* open the DRM device */ + ret = modeset_open(&fd, card); + if (ret) + goto out_return; + + /* prepare all connectors and CRTCs */ + ret = modeset_prepare(fd); + if (ret) + goto out_close; + + /* perform actual modesetting on each found connector+CRTC */ + for (iter = modeset_list; iter; iter = iter->next) { + iter->saved_crtc = drmModeGetCrtc(fd, iter->crtc); + ret = drmModeSetCrtc(fd, iter->crtc, iter->fb, 0, 0, + &iter->conn, 1, &iter->mode); + if (ret) + fprintf(stderr, "cannot set CRTC for connector %u (%d): %m\n", + iter->conn, errno); + } + + /* draw some colors for 5seconds */ + modeset_draw(); + + /* cleanup everything */ + modeset_cleanup(fd); + + ret = 0; + +out_close: + close(fd); +out_return: + if (ret) { + errno = -ret; + fprintf(stderr, "modeset failed with error %d: %m\n", errno); + } else { + fprintf(stderr, "exiting\n"); + } + return ret; +} + +/* + * A short helper function to compute a changing color value. No need to + * understand it. + */ + +static uint8_t next_color(bool *up, uint8_t cur, unsigned int mod) +{ + uint8_t next; + + next = cur + (*up ? 1 : -1) * (rand() % mod); + if ((*up && next < cur) || (!*up && next > cur)) { + *up = !*up; + next = cur; + } + + return next; +} + +/* + * modeset_draw(): This draws a solid color into all configured framebuffers. + * Every 100ms the color changes to a slightly different color so we get some + * kind of smoothly changing color-gradient. + * + * The color calculation can be ignored as it is pretty boring. So the + * interesting stuff is iterating over "modeset_list" and then through all lines + * and width. We then set each pixel individually to the current color. + * + * We do this 50 times as we sleep 100ms after each redraw round. This makes + * 50*100ms = 5000ms = 5s so it takes about 5seconds to finish this loop. + * + * Please note that we draw directly into the framebuffer. This means that you + * will see flickering as the monitor might refresh while we redraw the screen. + * To avoid this you would need to use two framebuffers and a call to + * drmModeSetCrtc() to switch between both buffers. + * You can also use drmModePageFlip() to do a vsync'ed pageflip. But this is + * beyond the scope of this document. + */ + +static void modeset_draw(void) +{ + uint8_t r, g, b; + bool r_up, g_up, b_up; + unsigned int i, j, k, off; + struct modeset_dev *iter; + + srand(time(NULL)); + r = rand() % 0xff; + g = rand() % 0xff; + b = rand() % 0xff; + r_up = g_up = b_up = true; + + for (i = 0; i < 50; ++i) { + r = next_color(&r_up, r, 20); + g = next_color(&g_up, g, 10); + b = next_color(&b_up, b, 5); + + for (iter = modeset_list; iter; iter = iter->next) { + for (j = 0; j < iter->height; ++j) { + for (k = 0; k < iter->width; ++k) { + off = iter->stride * j + k * 4; + *(uint32_t*)&iter->map[off] = + (r << 16) | (g << 8) | b; + } + } + } + + usleep(100000); + } +} + +/* + * modeset_cleanup(fd): This cleans up all the devices we created during + * modeset_prepare(). It resets the CRTCs to their saved states and deallocates + * all memory. + * It should be pretty obvious how all of this works. + */ + +static void modeset_cleanup(int fd) +{ + struct modeset_dev *iter; + struct drm_mode_destroy_dumb dreq; + + while (modeset_list) { + /* remove from global list */ + iter = modeset_list; + modeset_list = iter->next; + + /* restore saved CRTC configuration */ + drmModeSetCrtc(fd, + iter->saved_crtc->crtc_id, + iter->saved_crtc->buffer_id, + iter->saved_crtc->x, + iter->saved_crtc->y, + &iter->conn, + 1, + &iter->saved_crtc->mode); + drmModeFreeCrtc(iter->saved_crtc); + + /* unmap buffer */ + munmap(iter->map, iter->size); + + /* delete framebuffer */ + drmModeRmFB(fd, iter->fb); + + /* delete dumb buffer */ + memset(&dreq, 0, sizeof(dreq)); + dreq.handle = iter->handle; + drmIoctl(fd, DRM_IOCTL_MODE_DESTROY_DUMB, &dreq); + + /* free allocated memory */ + free(iter); + } +} + +/* + * I hope this was a short but easy overview of the DRM modesetting API. The DRM + * API offers much more capabilities including: + * - double-buffering or tripple-buffering (or whatever you want) + * - vsync'ed page-flips + * - hardware-accelerated rendering (for example via OpenGL) + * - output cloning + * - graphics-clients plus authentication + * - DRM planes/overlays/sprites + * - ... + * If you are interested in these topics, I can currently only redirect you to + * existing implementations, including: + * - plymouth (which uses dumb-buffers like this example; very easy to understand) + * - kmscon (which uses libuterm to do this) + * - wayland (very sophisticated DRM renderer; hard to understand fully as it + * uses more complicated techniques like DRM planes) + * - xserver (very hard to understand as it is split across many files/projects) + * + * But understanding how modesetting (as described in this document) works, is + * essential to understand all further DRM topics. + * + * Any feedback is welcome. Feel free to use this code freely for your own + * documentation or projects. + * + * - Hosted on http://github.com/dvdhrm/docs + * - Written by David Rheinsberg + */ From patchwork Mon Apr 25 07:59:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasyl Vavrychuk X-Patchwork-Id: 7087 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5711CC49EA5 for ; Mon, 25 Apr 2022 19:26:13 +0000 (UTC) Received: from repost01.tmes.trendmicro.eu (repost01.tmes.trendmicro.eu [18.185.115.7]) by mx.groups.io with SMTP id smtpd.web10.26691.1650873625898490034 for ; Mon, 25 Apr 2022 01:00:27 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@opensynergy.com header.s=tm-dkim-20210503141657 header.b=OfFClDbJ; spf=pass (domain: opensynergy.com, ip: 18.185.115.7, mailfrom: vasyl.vavrychuk@opensynergy.com) Received: from 104.47.17.107_.trendmicro.com (unknown [172.21.182.42]) by repost01.tmes.trendmicro.eu (Postfix) with SMTP id 79AF2100022FB for ; Mon, 25 Apr 2022 08:00:24 +0000 (UTC) X-TM-MAIL-RECEIVED-TIME: 1650873624.090000 X-TM-MAIL-UUID: ab3c4cdb-7ea8-4038-8c36-72a7b494bcad Received: from EUR05-DB8-obe.outbound.protection.outlook.com (unknown [104.47.17.107]) by repre01.tmes.trendmicro.eu (Trend Micro Email Security) with ESMTPS id 1619E10000E24 for ; Mon, 25 Apr 2022 08:00:24 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n0pW9csTZoC8G52TeCcmzPCwfwn+MwJvCOCHUjmtfhEusWImrdhSvgK+zcVxFNL/+VnDL3WQcuiVr2Wu1tnm+UUikpwYhc+sX8CXoIiunYOGok0+CX4Ny3bbfuVr1XdJSkO0EQ97pmw7gVBXJ8dwxJaXgiwKjLkux5ijzAhuBOtRrRgTh8bdrRWkKbcjYB52CcAMGSrPsPzMSX0ns9coC08eIkiNX+QxbKX9WOlpc2xMs84yUYx8uptWgBm27N+PUooYk8oZEOJS4X8NuOqred2XZ1BB//exNlHM5BKL9itM/+8ZI401HnnCBRW7S0WWyhVCyh6SFRBZ0SpBrdfPuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=uBD7leUTur9QpwLT2huL0YSS/Ul994dqEE3B19sOBdU=; b=gweLgY5CzGAmFzZ43qpv9EgBK2KQ8ACJLPZrH+IAV4TQl1DkKThGGqAx/FGXk92M/zNLgq2mBfBtX89Asd6P7kbj6peG0RG+jufWes+ryBFtDhiW0jCTR88e8oQK7udKJUtiM9FLAYGGDWYxA2l5WCxt4ZqPuA3R6AFu5fP76z84y4VNJbAffQNITqltIM4K9n7IMA0riwjmlo302xiHKN7Pvssrv/hGUFGpj9+8fLm1rf1SY8p/V46NH2f32F+M0rbedm7bhp3CTNwzYU8X+eKazIFUnnE/Sh4Xazysh+QN8yzglx1th/u/KA5j3AY3wOk64T+3rhYFrrOJ7JApaA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 217.66.60.4) smtp.rcpttodomain=lists.yoctoproject.org smtp.mailfrom=opensynergy.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=opensynergy.com; dkim=none (message not signed); arc=none X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 217.66.60.4) smtp.mailfrom=opensynergy.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=opensynergy.com; Received-SPF: Pass (protection.outlook.com: domain of opensynergy.com designates 217.66.60.4 as permitted sender) receiver=protection.outlook.com; client-ip=217.66.60.4; helo=SR-MAIL-03.open-synergy.com; From: Vasyl Vavrychuk To: yocto@lists.yoctoproject.org Cc: Vasyl Vavrychuk Subject: [psplash][RFC PATCH 11/14] Implement drm backend Date: Mon, 25 Apr 2022 10:59:51 +0300 Message-Id: <20220425075954.10427-12-vasyl.vavrychuk@opensynergy.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220425075954.10427-1-vasyl.vavrychuk@opensynergy.com> References: <20220425075954.10427-1-vasyl.vavrychuk@opensynergy.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 471eadec-7a70-4d68-a881-08da2691a605 X-MS-TrafficTypeDiagnostic: AM6PR04MB6583:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AVjKxAri2TOT77v8Ktl7MPHIC4nWxftoouIQsFSMFvLOQsF6X1VFdZc7iFW9YyMwoG1I8hMeez8yWpRp82+K0g+6NusEXBfXfHr9GCKMvUrz8CzHgwqk6bWa/OmVI0YGukC2uTzaVrLGSVrs1NuhLu5q3VlEeTB+zOmKwuniFayu9oGn5oPASrARs7rKlPGPedbLruHIvBpouy70dJA2gGmKY1rgql4yiW47D7Ih8qV4vZQtAEDqLaUo/nrrGrtUtKEJm5iPdptsaukLbx4Nbp+Ep3ZZF7hFudeeL0qgIi6pqYba80XV1FdJvfmB+aBt6sgF7ErnNMeRv9v1UlN7In2MRH0eXg1a8Vo51hkMq+2nhzPXK6uNnQf1mhbb3LgaLmlr7JnIA2E1X3Ojgy9hO2si22+QiwS6ehfKFdjQIzFtYoUqiRIW7vd0OrXaGCbw4EE5p4F6U5gQya6Whd0I8fDygLMfsC7WQZeRHu9322Pa7OfhxBzwHWYAdr6ucby8shYIr/Z+tRE0zLDNrD4Bm+ZdwslCUBL88EUsptdtL7SvOMlIQ1BMB0Ecj/ywoEGYGRXa5bl2Ujq/+5FTNW7RnW4LxylqNQx6OXqzJedEsaGyQNFn9CpBTfzgP5AIHoJuMY5C5BgVCxlpn8dySKNNnKWkn7YAWY6+D3FZuW/8ZXVAuXlxnijfGF0nnulx08n7 X-Forefront-Antispam-Report: CIP:217.66.60.4;CTRY:DE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SR-MAIL-03.open-synergy.com;PTR:mx1.opensynergy.com;CAT:NONE;SFS:(13230001)(376002)(39830400003)(346002)(136003)(396003)(36840700001)(46966006)(40480700001)(2906002)(36756003)(81166007)(82310400005)(5660300002)(508600001)(70586007)(6916009)(316002)(42186006)(70206006)(8676002)(36860700001)(26005)(83380400001)(86362001)(44832011)(8936002)(30864003)(4326008)(336012)(186003)(2616005)(47076005)(107886003)(1076003);DIR:OUT;SFP:1102; X-OriginatorOrg: opensynergy.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2022 08:00:22.3067 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 471eadec-7a70-4d68-a881-08da2691a605 X-MS-Exchange-CrossTenant-Id: 800fae25-9b1b-4edc-993d-c939c4e84a64 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=800fae25-9b1b-4edc-993d-c939c4e84a64;Ip=[217.66.60.4];Helo=[SR-MAIL-03.open-synergy.com] X-MS-Exchange-CrossTenant-AuthSource: AM6EUR05FT003.eop-eur05.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB6583 X-TM-AS-ERS: 104.47.17.107-0.0.0.0 X-TMASE-Version: StarCloud-1.3-8.8.1001-26854.006 X-TMASE-Result: 10--6.188900-4.000000 X-TMASE-MatchedRID: JQzBjI30y8cJZTtfNSpVibnHu4BcYSmtP8UQejhp29rAuQ0xDMaXkH4q tYI9sRE/KWDiOlctVrMsl4wNHv2V1qhcbBawps00yCvBIqsqjUfvG0/D/wjsdA3H/quqvfm40A4 5IAXRxM17lDwo3ADxWZ+lLx92IzG5Z/BO1YTyvqbPtRnYhgu+5NhQO8CvZj/XxeXyNOAaNeKnoz pkCB2KZOizH5nuc4ffey+HceM/tEAgLGzZISHnAQUkbxmZfIp1joRIaAJe+CgiBHFGm3BvRMDlp 28LM+NynVDT62eTguEHiBVKKaTKWTa7IBuOPthElTsGW3DmpUspA2ExuipmWrs3Yh2IOCYzFmWO XOcXhvP93kA1ImA+YDaRYhTCl/DReRo9SVpFyixntEdzQBf3IQT2OEnoCt48Br7dUnIrjPa6k6K y999wUGjgSQDPsC0c1/J/9lMmdnO52NE9L0fCNLxygpRxo469NUSduuqYHDuu9yzHHu0ZiT6A6/ U7ZwHgULd14sEtBkGZjh1sP0xNhsGK+Foq9+Eo+GYt8f/VhTvEybY/hBC6uuX3QlUHePIKAG0zw X6Z64MP84WlxIC/C9kxcnCbMe2ylwV2iaAfSWdRGaeOJTnMWxnUJ0Ek6yhjxEHRux+uk8h+ICqu Ni0WJEZie4SGLCIT8Gzh4xxq0/if8QwZ94kF0EM2OIUy/z5sftwZ3X11IV0= X-TMASE-XGENCLOUD: 1ff5cc26-e7ab-4a7c-9149-56a044749ac0-0-0-200-0 X-TM-Deliver-Signature: 550E055018927FF1F0E32AD3EE3C6652 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=opensynergy.com; s=TM-DKIM-20210503141657; t=1650873624; bh=GPzH95uiD1lOQx3TOn6cTKDMCjLwYO1HztjXWLV7Vtk=; l=13885; h=From:To:Date; b=OfFClDbJH+gxbaV4tDl6uhOPuGLA+B+3YAEixXPYfGx5NbRcjdwSFWWqiXxZt1dAJ W4YVfFI2nLTLtIKKVzw3OUDcEiSuWJIViYeEyiOw+ES82Mn1IcqTlOB2UfVg+6kHJp Wfz9NZ3XfmejbL9VYiXQdHrejQfHcUN6cDGksVirfBg8HlVeJuOq2YN1cmEaeQgK2w Y5mVqHHKSy5RZOqv7dHqimCFPZ171QhHjUO7eVeQXc//lViXytOXsGkaUjnB6q/pim SYXInylZtSCnXzfg6CZp9yQvjvUTQRWmZrrdy9vlKhT8A1nQgqOgKeV/dkqftznXE0 wVDWWYM7H/ciw== List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 25 Apr 2022 19:26:13 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto/message/56862 Limitation is that splash screen is drawn only on the first connector. Signed-off-by: Vasyl Vavrychuk --- Makefile.am | 12 +++- configure.ac | 9 +++ psplash-drm.c | 179 +++++++++++++++++--------------------------------- psplash-drm.h | 17 +++++ psplash.c | 52 +++++++++++---- 5 files changed, 135 insertions(+), 134 deletions(-) create mode 100644 psplash-drm.h diff --git a/Makefile.am b/Makefile.am index 375b926..c3d4f03 100644 --- a/Makefile.am +++ b/Makefile.am @@ -8,12 +8,20 @@ psplash_SOURCES = psplash.c psplash.h psplash-fb.c psplash-fb.h \ psplash-poky-img.h psplash-bar-img.h $(FONT_NAME)-font.h \ psplash-draw.c psplash-draw.h BUILT_SOURCES = psplash-poky-img.h psplash-bar-img.h +psplash_CPPFLAGS = +psplash_LDFLAGS = psplash_write_SOURCES = psplash-write.c psplash.h +if ENABLE_DRM +psplash_SOURCES += psplash-drm.c psplash-drm.h +psplash_CPPFLAGS += $(LIBDRM_CFLAGS) -DENABLE_DRM +psplash_LDFLAGS += $(LIBDRM_LIBS) +endif + if HAVE_SYSTEMD -psplash_CPPFLAGS = $(SYSTEMD_CFLAGS) -DHAVE_SYSTEMD -psplash_LDFLAGS= $(SYSTEMD_LIBS) +psplash_CPPFLAGS += $(SYSTEMD_CFLAGS) -DHAVE_SYSTEMD +psplash_LDFLAGS += $(SYSTEMD_LIBS) bin_PROGRAMS += psplash-systemd psplash_systemd_CPPFLAGS = $(SYSTEMD_CFLAGS) psplash_systemd_LDFLAGS= $(SYSTEMD_LIBS) diff --git a/configure.ac b/configure.ac index 2a7da91..2e5c4f5 100644 --- a/configure.ac +++ b/configure.ac @@ -12,6 +12,15 @@ if test "x$GCC" = "xyes"; then GCC_FLAGS="-g -Wall -Wextra" fi +AC_ARG_ENABLE(drm, + AS_HELP_STRING([--enable-drm], [enable drm backend (default is 'no')])) + +AS_IF([test "x$enable_drm" = "xyes"], [ + PKG_CHECK_MODULES(LIBDRM, libdrm) +]) + +AM_CONDITIONAL([ENABLE_DRM], [test "x$enable_drm" = "xyes"]) + AC_ARG_WITH([systemd], AS_HELP_STRING([--with-systemd], [Build with systemd support])) diff --git a/psplash-drm.c b/psplash-drm.c index c9a9f5c..30850ed 100644 --- a/psplash-drm.c +++ b/psplash-drm.c @@ -26,10 +26,8 @@ * provided by some external library. */ -#define _GNU_SOURCE #include #include -#include #include #include #include @@ -39,6 +37,7 @@ #include #include #include +#include "psplash-drm.h" struct modeset_dev; static int modeset_find_crtc(int fd, drmModeRes *res, drmModeConnector *conn, @@ -48,8 +47,6 @@ static int modeset_setup_dev(int fd, drmModeRes *res, drmModeConnector *conn, struct modeset_dev *dev); static int modeset_open(int *out, const char *node); static int modeset_prepare(int fd); -static void modeset_draw(void); -static void modeset_cleanup(int fd); /* * When the linux kernel detects a graphics-card on your machine, it loads the @@ -153,7 +150,7 @@ struct modeset_dev { uint32_t stride; uint32_t size; uint32_t handle; - uint8_t *map; + void *map; drmModeModeInfo mode; uint32_t fb; @@ -187,7 +184,7 @@ static int modeset_prepare(int fd) { drmModeRes *res; drmModeConnector *conn; - unsigned int i; + int i; struct modeset_dev *dev; int ret; @@ -338,11 +335,10 @@ static int modeset_find_crtc(int fd, drmModeRes *res, drmModeConnector *conn, struct modeset_dev *dev) { drmModeEncoder *enc; - unsigned int i, j; - int32_t crtc; + int i, j, crtc; struct modeset_dev *iter; - /* first try the currently conected encoder+crtc */ + /* first try the currently connected encoder+crtc */ if (conn->encoder_id) enc = drmModeGetEncoder(fd, conn->encoder_id); else @@ -352,7 +348,7 @@ static int modeset_find_crtc(int fd, drmModeRes *res, drmModeConnector *conn, if (enc->crtc_id) { crtc = enc->crtc_id; for (iter = modeset_list; iter; iter = iter->next) { - if (iter->crtc == crtc) { + if (iter->crtc == (uint32_t)crtc) { crtc = -1; break; } @@ -389,7 +385,7 @@ static int modeset_find_crtc(int fd, drmModeRes *res, drmModeConnector *conn, /* check that no other device already uses this CRTC */ crtc = res->crtcs[j]; for (iter = modeset_list; iter; iter = iter->next) { - if (iter->crtc == crtc) { + if (iter->crtc == (uint32_t)crtc) { crtc = -1; break; } @@ -503,6 +499,12 @@ err_destroy: return ret; } +static void psplash_drm_flip(PSplashCanvas *canvas, int sync) +{ + (void)canvas; + (void)sync; +} + /* * Finally! We have a connector with a suitable CRTC. We know which mode we want * to use and we have a framebuffer of the correct size that we can write to. @@ -532,155 +534,89 @@ err_destroy: * also often not guaranteed. So instead, we only use one connector per CRTC. * * Before calling drmModeSetCrtc() we also save the current CRTC configuration. - * This is used in modeset_cleanup() to restore the CRTC to the same mode as was - * before we changed it. + * This is used in psplash_drm_destroy() to restore the CRTC to the same mode as + * was before we changed it. * If we don't do this, the screen will stay blank after we exit until another * application performs modesetting itself. */ -int main(int argc, char **argv) +PSplashDRM* psplash_drm_new(int angle, int dev_id) { - int ret, fd; - const char *card; + PSplashDRM *drm = NULL; + int ret; + char card[] = "/dev/dri/card0"; struct modeset_dev *iter; - /* check which DRM device to open */ - if (argc > 1) - card = argv[1]; - else - card = "/dev/dri/card0"; + if ((drm = malloc(sizeof(*drm))) == NULL) { + perror("malloc"); + goto error; + } + drm->canvas.priv = drm; + drm->canvas.flip = psplash_drm_flip; + + if (dev_id > 0 && dev_id < 10) { + // Conversion from integer to ascii. + card[13] = dev_id + 48; + } fprintf(stderr, "using card '%s'\n", card); /* open the DRM device */ - ret = modeset_open(&fd, card); + ret = modeset_open(&drm->fd, card); if (ret) - goto out_return; + goto error; /* prepare all connectors and CRTCs */ - ret = modeset_prepare(fd); + ret = modeset_prepare(drm->fd); if (ret) - goto out_close; + goto error; /* perform actual modesetting on each found connector+CRTC */ for (iter = modeset_list; iter; iter = iter->next) { - iter->saved_crtc = drmModeGetCrtc(fd, iter->crtc); - ret = drmModeSetCrtc(fd, iter->crtc, iter->fb, 0, 0, + iter->saved_crtc = drmModeGetCrtc(drm->fd, iter->crtc); + ret = drmModeSetCrtc(drm->fd, iter->crtc, iter->fb, 0, 0, &iter->conn, 1, &iter->mode); if (ret) fprintf(stderr, "cannot set CRTC for connector %u (%d): %m\n", iter->conn, errno); } - /* draw some colors for 5seconds */ - modeset_draw(); - - /* cleanup everything */ - modeset_cleanup(fd); - - ret = 0; - -out_close: - close(fd); -out_return: - if (ret) { - errno = -ret; - fprintf(stderr, "modeset failed with error %d: %m\n", errno); - } else { - fprintf(stderr, "exiting\n"); - } - return ret; + drm->canvas.data = modeset_list->map; + drm->canvas.width = modeset_list->width; + drm->canvas.height = modeset_list->height; + drm->canvas.bpp = 32; + drm->canvas.stride = modeset_list->stride; + drm->canvas.angle = angle; + drm->canvas.rgbmode = RGB888; + + return drm; +error: + psplash_drm_destroy(drm); + return NULL; } /* - * A short helper function to compute a changing color value. No need to - * understand it. - */ - -static uint8_t next_color(bool *up, uint8_t cur, unsigned int mod) -{ - uint8_t next; - - next = cur + (*up ? 1 : -1) * (rand() % mod); - if ((*up && next < cur) || (!*up && next > cur)) { - *up = !*up; - next = cur; - } - - return next; -} - -/* - * modeset_draw(): This draws a solid color into all configured framebuffers. - * Every 100ms the color changes to a slightly different color so we get some - * kind of smoothly changing color-gradient. - * - * The color calculation can be ignored as it is pretty boring. So the - * interesting stuff is iterating over "modeset_list" and then through all lines - * and width. We then set each pixel individually to the current color. - * - * We do this 50 times as we sleep 100ms after each redraw round. This makes - * 50*100ms = 5000ms = 5s so it takes about 5seconds to finish this loop. - * - * Please note that we draw directly into the framebuffer. This means that you - * will see flickering as the monitor might refresh while we redraw the screen. - * To avoid this you would need to use two framebuffers and a call to - * drmModeSetCrtc() to switch between both buffers. - * You can also use drmModePageFlip() to do a vsync'ed pageflip. But this is - * beyond the scope of this document. - */ - -static void modeset_draw(void) -{ - uint8_t r, g, b; - bool r_up, g_up, b_up; - unsigned int i, j, k, off; - struct modeset_dev *iter; - - srand(time(NULL)); - r = rand() % 0xff; - g = rand() % 0xff; - b = rand() % 0xff; - r_up = g_up = b_up = true; - - for (i = 0; i < 50; ++i) { - r = next_color(&r_up, r, 20); - g = next_color(&g_up, g, 10); - b = next_color(&b_up, b, 5); - - for (iter = modeset_list; iter; iter = iter->next) { - for (j = 0; j < iter->height; ++j) { - for (k = 0; k < iter->width; ++k) { - off = iter->stride * j + k * 4; - *(uint32_t*)&iter->map[off] = - (r << 16) | (g << 8) | b; - } - } - } - - usleep(100000); - } -} - -/* - * modeset_cleanup(fd): This cleans up all the devices we created during + * psplash_drm_destroy(drm): This cleans up all the devices we created during * modeset_prepare(). It resets the CRTCs to their saved states and deallocates * all memory. * It should be pretty obvious how all of this works. */ -static void modeset_cleanup(int fd) +void psplash_drm_destroy(PSplashDRM *drm) { struct modeset_dev *iter; struct drm_mode_destroy_dumb dreq; + if (!drm) + return; + while (modeset_list) { /* remove from global list */ iter = modeset_list; modeset_list = iter->next; /* restore saved CRTC configuration */ - drmModeSetCrtc(fd, + drmModeSetCrtc(drm->fd, iter->saved_crtc->crtc_id, iter->saved_crtc->buffer_id, iter->saved_crtc->x, @@ -694,16 +630,19 @@ static void modeset_cleanup(int fd) munmap(iter->map, iter->size); /* delete framebuffer */ - drmModeRmFB(fd, iter->fb); + drmModeRmFB(drm->fd, iter->fb); /* delete dumb buffer */ memset(&dreq, 0, sizeof(dreq)); dreq.handle = iter->handle; - drmIoctl(fd, DRM_IOCTL_MODE_DESTROY_DUMB, &dreq); + drmIoctl(drm->fd, DRM_IOCTL_MODE_DESTROY_DUMB, &dreq); /* free allocated memory */ free(iter); } + + close(drm->fd); + free(drm); } /* diff --git a/psplash-drm.h b/psplash-drm.h new file mode 100644 index 0000000..e987fd6 --- /dev/null +++ b/psplash-drm.h @@ -0,0 +1,17 @@ +#ifndef _HAVE_PSPLASH_DRM_H +#define _HAVE_PSPLASH_DRM_H + +#include "psplash-draw.h" + +typedef struct PSplashDRM +{ + PSplashCanvas canvas; + int fd; +} +PSplashDRM; + +void psplash_drm_destroy(PSplashDRM *drm); + +PSplashDRM* psplash_drm_new(int angle, int dev_id); + +#endif diff --git a/psplash.c b/psplash.c index 036dfb1..ebf8d7a 100644 --- a/psplash.c +++ b/psplash.c @@ -12,6 +12,9 @@ #include "psplash.h" #include "psplash-fb.h" +#ifdef ENABLE_DRM +#include "psplash-drm.h" +#endif #include "psplash-config.h" #include "psplash-colors.h" #include "psplash-poky-img.h" @@ -224,8 +227,11 @@ int main (int argc, char** argv) { char *rundir; - int pipe_fd, i = 0, angle = 0, fbdev_id = 0, ret = 0; - PSplashFB *fb; + int pipe_fd, i = 0, angle = 0, dev_id = 0, use_drm = 0, ret = 0; + PSplashFB *fb = NULL; +#ifdef ENABLE_DRM + PSplashDRM *drm = NULL; +#endif PSplashCanvas *canvas; bool disable_console_switch = FALSE; @@ -247,16 +253,24 @@ main (int argc, char** argv) continue; } - if (!strcmp(argv[i],"-f") || !strcmp(argv[i],"--fbdev")) + if (!strcmp(argv[i], "-f") || !strcmp(argv[i], "--fbdev") || + !strcmp(argv[i], "-d") || !strcmp(argv[i], "--dev")) { if (++i >= argc) goto fail; - fbdev_id = atoi(argv[i]); + dev_id = atoi(argv[i]); continue; } +#ifdef ENABLE_DRM + if (!strcmp(argv[i], "--drm")) { + use_drm = 1; + continue; + } +#endif + fail: fprintf(stderr, - "Usage: %s [-n|--no-console-switch][-a|--angle <0|90|180|270>][-f|--fbdev <0..9>]\n", + "Usage: %s [-n|--no-console-switch][-a|--angle <0|90|180|270>][-f|--fbdev|-d|--dev <0..9>][--drm]\n", argv[0]); exit(-1); } @@ -291,12 +305,21 @@ main (int argc, char** argv) if (!disable_console_switch) psplash_console_switch (); - if ((fb = psplash_fb_new(angle,fbdev_id)) == NULL) - { - ret = -1; - goto fb_fail; + if (use_drm) { +#ifdef ENABLE_DRM + if ((drm = psplash_drm_new(angle, dev_id)) == NULL) { + ret = -1; + goto error; + } + canvas = &drm->canvas; +#endif + } else { + if ((fb = psplash_fb_new(angle, dev_id)) == NULL) { + ret = -1; + goto error; } - canvas = &fb->canvas; + canvas = &fb->canvas; + } #ifdef HAVE_SYSTEMD sd_notify(0, "READY=1"); @@ -349,9 +372,14 @@ main (int argc, char** argv) psplash_main(canvas, pipe_fd, 0); - psplash_fb_destroy (fb); + if (fb) + psplash_fb_destroy(fb); +#ifdef ENABLE_DRM + if (drm) + psplash_drm_destroy(drm); +#endif - fb_fail: + error: unlink(PSPLASH_FIFO); if (!disable_console_switch) From patchwork Mon Apr 25 07:59:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasyl Vavrychuk X-Patchwork-Id: 7084 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68429C54EC5 for ; Mon, 25 Apr 2022 19:26:13 +0000 (UTC) Received: from repost01.tmes.trendmicro.eu (repost01.tmes.trendmicro.eu [18.185.115.6]) by mx.groups.io with SMTP id smtpd.web09.26984.1650873627127755678 for ; Mon, 25 Apr 2022 01:00:27 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@opensynergy.com header.s=tm-dkim-20210503141657 header.b=iyB13wSh; spf=pass (domain: opensynergy.com, ip: 18.185.115.6, mailfrom: vasyl.vavrychuk@opensynergy.com) Received: from 104.47.17.174_.trendmicro.com (unknown [172.21.180.2]) by repost01.tmes.trendmicro.eu (Postfix) with SMTP id AD966100022E1 for ; Mon, 25 Apr 2022 08:00:25 +0000 (UTC) X-TM-MAIL-RECEIVED-TIME: 1650873625.073000 X-TM-MAIL-UUID: cc68405b-88d9-4915-b0a6-cbd770e69ee9 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (unknown [104.47.17.174]) by repre01.tmes.trendmicro.eu (Trend Micro Email Security) with ESMTPS id 11F5C10002D3E for ; Mon, 25 Apr 2022 08:00:24 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MZpIc5ygoLRBMi4w3rQWboBGr8MTXMhWRW8MrBY9Njdl7nmENZldtpMywNpRcK+MWfoLzR35nWlkcPuYYueU1F3DyNTwbxg2w+kg0xiAfCryaF56xBej0to/9/M6+PaRC2MS1CMNALgbWVx3n9yELhmq7PN8x5d/LnCo80RnM6OQcV5ER2qjV45hqWBNRJune9/9rBd9i8TNVW5HYLrKyHrLLqSxoTlu41TxEJn069r8UIbeachWGebE9P6K+Q+kY1RPVVsylR7c9GsPDjN9wV5jCjvf8K4HzHb2XQ+7KWl9AtMZ3R83tIFp/vHht6IyOZVKvnkkQGVkFnQRldMg2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=0fJ3ira3RimZtXr6e2Ti9sIIkmIMvarpqBTMt746Tnw=; b=e6tok5DuconW1Eslw1X1LHHW1+XJRBXN6dIAmU0voWr1IVuE9snhXXG9JvQT4ina929CE26lRXT6pYgVVD4oRgLI6MhcEWDaNEPhVWfahoXgpyWFtAC1lfGME4CdVv0mDOf7HiKDjraTIfWYRftUM++i13mwNSnRAfCPTOY8GIrh4lqRmvnVEmY2Uzh+/Axt3XKUCkNPJJKI62nMdBdPnaV0JcDfbmiriXuQ8pTojv7YbTqJxpZ1iP2dotig+nG1y42hdGYmiEPpel2enhGJhOw8W/NThklptqTtoQbgQJfXSb+kO3OpffDgq/G2ULQlzAvRmaaZXpIB+ZvB6KXyDg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 217.66.60.4) smtp.rcpttodomain=lists.yoctoproject.org smtp.mailfrom=opensynergy.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=opensynergy.com; dkim=none (message not signed); arc=none X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 217.66.60.4) smtp.mailfrom=opensynergy.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=opensynergy.com; Received-SPF: Pass (protection.outlook.com: domain of opensynergy.com designates 217.66.60.4 as permitted sender) receiver=protection.outlook.com; client-ip=217.66.60.4; helo=SR-MAIL-03.open-synergy.com; From: Vasyl Vavrychuk To: yocto@lists.yoctoproject.org Cc: Vasyl Vavrychuk Subject: [psplash][RFC PATCH 12/14] Reverse modeset_list Date: Mon, 25 Apr 2022 10:59:52 +0300 Message-Id: <20220425075954.10427-13-vasyl.vavrychuk@opensynergy.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220425075954.10427-1-vasyl.vavrychuk@opensynergy.com> References: <20220425075954.10427-1-vasyl.vavrychuk@opensynergy.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2ae5129b-f70d-40a0-1d31-08da2691a631 X-MS-TrafficTypeDiagnostic: DU2PR04MB8775:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GLU2x5BqbrSvnNieJyqvhVN5HyvqGl5tjuLKodldn8ui2Fqg7uXi1Q74sAzXznjpXTobf48lbfsCR8I4yeU2W0U4CVjzTKbVM94+VqLXEkuknEIk7/UH1nI27uT2z1dRkFyjE9vCRdjQPCzGjAFJtavdLLx/5j1VTHY6X14RG+dF06R/L0x+pyZI3AEcCbhJfUBczsQNBPixWUF/aNO2S8l8WHIQCvx4ys3HfyKkFSYMft4VExVDmM9biVn+1BR2dzbtoxzsPypZt+oe3d/mc1wUwwilT6balOWnO5AjBhOmLQurpGuGgjnHdeW6c5fOM91cUH2OWxEdcJiaPcZ0s3szr8plpWE9uchPjGBkzu+jYjE+Ca+WFIG8NOUMIHdiDvSDHAAgYdPdWD8i/GIPwD9PGQ9t21NGHr+KcNloKlRR3dRSwd/WwAVb6PLtoi6Z9uU/UuMCdVpIcWmFsKGBLymxgSJ6E2eKh0Og8ckafUfy6pS9RX4ZRjAy6N5c2vpeTsaHKiQFxz0M5Zczw78aXvGsg/HXRS6QLsDpko+knjgX8Paj3OPAFi4mktsCLw9qXEhGfFKmKxoJ0URfJsaGssPGY69/SvvkGXtMPkPFPTo1zgEXkePXruaTAGE72GTkc2SzPZr15McBqp0oxjNRjQhPeTypgZb/aFINfNv1AOcJBrzl54veqnwJY+j6t6Vl X-Forefront-Antispam-Report: CIP:217.66.60.4;CTRY:DE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SR-MAIL-03.open-synergy.com;PTR:mx1.opensynergy.com;CAT:NONE;SFS:(13230001)(376002)(136003)(346002)(396003)(39830400003)(46966006)(36840700001)(42186006)(82310400005)(186003)(6916009)(47076005)(83380400001)(40480700001)(336012)(8676002)(36756003)(36860700001)(316002)(81166007)(4326008)(70206006)(5660300002)(70586007)(107886003)(2616005)(26005)(8936002)(508600001)(1076003)(4744005)(86362001)(44832011)(2906002);DIR:OUT;SFP:1102; X-OriginatorOrg: opensynergy.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2022 08:00:22.5915 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2ae5129b-f70d-40a0-1d31-08da2691a631 X-MS-Exchange-CrossTenant-Id: 800fae25-9b1b-4edc-993d-c939c4e84a64 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=800fae25-9b1b-4edc-993d-c939c4e84a64;Ip=[217.66.60.4];Helo=[SR-MAIL-03.open-synergy.com] X-MS-Exchange-CrossTenant-AuthSource: AM6EUR05FT059.eop-eur05.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8775 X-TM-AS-ERS: 104.47.17.174-0.0.0.0 X-TMASE-Version: StarCloud-1.3-8.8.1001-26854.006 X-TMASE-Result: 10--0.029000-4.000000 X-TMASE-MatchedRID: 8qzDc62TWy8dh0bHKS/78q7i5EFUmYlswTlc9CcHMZerwqxtE531VICu qghmtWfXpCZmRBaJ+pgv/zJQ0aiPJvvlwQ3r+q9MEVuC0eNRYvK0aicQ5bmD5umdrzaSKL9co8W MkQWv6iXjCeE5v4lH5MIJ+4gwXrEtIAcCikR3vq9Q7u8u2aInpnwG9xzBAxOt1cJ8itq6ieAWDx j4ju31axv552Yh5Qzk X-TMASE-XGENCLOUD: e5184981-13e8-498e-a331-6ac041344fe6-0-0-200-0 X-TM-Deliver-Signature: 51E2C9B46A956B407FBFAE41D64403ED DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=opensynergy.com; s=TM-DKIM-20210503141657; t=1650873625; bh=Tx0OjK3zkLmy/uzPIAmN4bfi0nso0c4fTi880kxFxmE=; l=1035; h=From:To:Date; b=iyB13wShqLm59YH4rIemX1oQlczhVO9oJ4Uv6YESmkp5QE5GRB4Xxx+0JEARrbIPF W3E910+0QdiVc3txVeKYAfxFvFnLkUyc3DsaowBuNGtriq4yFrnibdZZrcauMt2Qux jyiXan3LPp03fqrFW5ZnMEIjeNavhif0559BxUAI9udVw5I3ahaQFCf0WqXlM+CBoo swcP1zEbPqRa22yZHComHG/R5H0fu3OB7GV+8uS1JdhSSg9Py5mu4jt25uYdCadzHt 3VR3r11SLiyI1cfirigNV+KH/R8BXhPSFiq9V+pvrOFZKRgdZK5Jv4F1Zy8ob60Dwv Qk3Njwjkcwl0A== List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 25 Apr 2022 19:26:13 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto/message/56865 Now, it has the same order as connectors in drmModeGetResources. As result splash screen will be drawn on the first connector. Signed-off-by: Vasyl Vavrychuk --- psplash-drm.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/psplash-drm.c b/psplash-drm.c index 30850ed..2468cf1 100644 --- a/psplash-drm.c +++ b/psplash-drm.c @@ -185,7 +185,7 @@ static int modeset_prepare(int fd) drmModeRes *res; drmModeConnector *conn; int i; - struct modeset_dev *dev; + struct modeset_dev *dev, *last_dev = NULL; int ret; /* retrieve resources */ @@ -226,8 +226,13 @@ static int modeset_prepare(int fd) /* free connector data and link device into global list */ drmModeFreeConnector(conn); - dev->next = modeset_list; - modeset_list = dev; + if (last_dev == NULL) { + modeset_list = dev; + last_dev = dev; + } else { + last_dev->next = dev; + last_dev = dev; + } } /* free resources again */ From patchwork Mon Apr 25 07:59:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasyl Vavrychuk X-Patchwork-Id: 7091 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 82D2AC48BE6 for ; Mon, 25 Apr 2022 19:26:13 +0000 (UTC) Received: from repost01.tmes.trendmicro.eu (repost01.tmes.trendmicro.eu [18.185.115.26]) by mx.groups.io with SMTP id smtpd.web10.26693.1650873631846550782 for ; Mon, 25 Apr 2022 01:00:32 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@opensynergy.com header.s=tm-dkim-20210503141657 header.b=Brn0EHie; spf=pass (domain: opensynergy.com, ip: 18.185.115.26, mailfrom: vasyl.vavrychuk@opensynergy.com) Received: from 104.47.17.175_.trendmicro.com (unknown [172.21.163.172]) by repost01.tmes.trendmicro.eu (Postfix) with SMTP id EDD96100004DB for ; Mon, 25 Apr 2022 08:00:29 +0000 (UTC) X-TM-MAIL-RECEIVED-TIME: 1650873626.609000 X-TM-MAIL-UUID: 1fc9125f-038b-44cf-95fd-427745e77319 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (unknown [104.47.17.175]) by repre01.tmes.trendmicro.eu (Trend Micro Email Security) with ESMTPS id 94CA110001756 for ; Mon, 25 Apr 2022 08:00:26 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d4jWifrZGftU+ijYACgldWHYZr5TGKXl15PYCTGCCcDzSKGofAQvR9PoT1coJm6cEl7tMujZx2Fk5BNti9onm00Dn1KOPsvAtxb5uM692HZTYH/XaS3bU8V7XFQrbe51wgp+c+y/dEzD2d3ctZh0R99VyHX6T7Fy1GcT1XwvIaAhn3e/1xD0yySI5oFi+DlMkhGb1E0AxeLmIgG0bXRZNDkMeMeNIyi2lOfCtNJg/ElKJktj2ZD1iJk1X/nsE7EtlFczuQUrMnWzMG7l0cWILvuAOEk5ksG/EMgNDTBY+twVQDcNQk1HWKuBktjCmwjD0NW9qdwG/T9UxmRSWUJpdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ava69eCTuamIUHIQ5hfu/j47Jcr7rNxY6PIfgLf2k88=; b=bMjQ8LAnZUeNG2cOlCH0/t0kfdQRuKMaJFqNPS4s4PwpKi2yi8RFyhLrvWK4s4UzqPfzLzh7JpwrbX6H6tmeodi65BaSduH0iUneO187tHfapwoqRk0gGask+5Z8taKyjez6ViVya9Zibkhshq8Ch5FgvHVV0DQ53y1RckhMFqSr460y3nh3GXoXadWf14ia6nSW0j/L8hGJzDV4zfGojhCKFUenpBe7Vxeqi6cl+Ew017vmofqALZTELR7CY5g01ZXeX2Fq6Id+nW3XHTKd0z54OWLU+UojFtLR2Z050i0Dv8YZCPzlXm7Kvs48vUlKekyW61WTAmClmJZ7HMvcSg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 217.66.60.4) smtp.rcpttodomain=lists.yoctoproject.org smtp.mailfrom=opensynergy.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=opensynergy.com; dkim=none (message not signed); arc=none X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 217.66.60.4) smtp.mailfrom=opensynergy.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=opensynergy.com; Received-SPF: Pass (protection.outlook.com: domain of opensynergy.com designates 217.66.60.4 as permitted sender) receiver=protection.outlook.com; client-ip=217.66.60.4; helo=SR-MAIL-03.open-synergy.com; From: Vasyl Vavrychuk To: yocto@lists.yoctoproject.org Cc: Vasyl Vavrychuk Subject: [psplash][RFC PATCH 13/14] psplash-drm.c: Allocate resources only for the first connector Date: Mon, 25 Apr 2022 10:59:53 +0300 Message-Id: <20220425075954.10427-14-vasyl.vavrychuk@opensynergy.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220425075954.10427-1-vasyl.vavrychuk@opensynergy.com> References: <20220425075954.10427-1-vasyl.vavrychuk@opensynergy.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ef7a7f2a-f492-4500-b0dc-08da2691a665 X-MS-TrafficTypeDiagnostic: HE1PR0401MB2668:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VI4dMtl2EWiTb1Fl2kc1b/qeE4V4+vvFNYYzuc4fpVYkV1+lMz8tVfcl90Z7O1wy0B07S6ctu1tB232bxmbBryp5nlmSGePRifguvY8y/T72AJvHSbkJmommnWDIiyH4GaBp5ljhxsDs7Ph1fmohTbHGYBoCFYCSU5GY6weAjSPuDNxhbRrtd4H5uTXmstEwti5dFnvmSd6F80Z2c+9y5ENQmZCeLqp7eYmtwJS7qEUU2XNoVIeIqOzY7Qt2epV2FMf40O31gFazQ+BvANUqPaib7XD+nA3N60DD9LcSlpBl0fSS1ND2ZTHJroSEj6uDBzynoobosRCsrj2NDTJjD2LhB3YK28y3xmWesLn0wRjq4n66iFuAaHwq558ZyIZTR7Kh36Yy07ks4KrKBunMBENGK+NFggOrELtXmbQWF08gR0zYRUdQ0o/FDV93UdSXFp7ZLeLg6tWI3jnVXbloXocBfQRQUCKYPjXqJxNq6xmsnH0Zq9xcxiXeE3XpggQveC7ElnxbFk05eDRqbVc2f3/+nD2rkfBuCpbVVVF4xmm1IC4wAWDVgMb7prpFfd/JrKr2BE72TY//67Qmmjvrn64abwfRqcwfrC/yAZvayYgwZzAQUftpvgloA2xMwAv/UU6lfrevnGFPiOVNEodqa+R0wiKy1HbjEujYq49r20Yqw948TB7UBWYRn8mK4RkE X-Forefront-Antispam-Report: CIP:217.66.60.4;CTRY:DE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SR-MAIL-03.open-synergy.com;PTR:mx1.opensynergy.com;CAT:NONE;SFS:(13230001)(396003)(376002)(39830400003)(346002)(136003)(46966006)(36840700001)(86362001)(40480700001)(47076005)(1076003)(5660300002)(2616005)(81166007)(508600001)(8936002)(44832011)(2906002)(107886003)(83380400001)(36860700001)(8676002)(186003)(82310400005)(42186006)(70586007)(70206006)(4326008)(336012)(26005)(316002)(6916009)(36756003);DIR:OUT;SFP:1102; X-OriginatorOrg: opensynergy.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2022 08:00:22.9204 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ef7a7f2a-f492-4500-b0dc-08da2691a665 X-MS-Exchange-CrossTenant-Id: 800fae25-9b1b-4edc-993d-c939c4e84a64 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=800fae25-9b1b-4edc-993d-c939c4e84a64;Ip=[217.66.60.4];Helo=[SR-MAIL-03.open-synergy.com] X-MS-Exchange-CrossTenant-AuthSource: VI1EUR05FT020.eop-eur05.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0401MB2668 X-TM-AS-ERS: 104.47.17.175-0.0.0.0 X-TMASE-Version: StarCloud-1.3-8.8.1001-26854.006 X-TMASE-Result: 10--1.866700-4.000000 X-TMASE-MatchedRID: 6Rb6MxL3kQhc4VNP6KaaNk7nLUqYrlslFIuBIWrdOePfUZT83lbkEB/a 4gy0uyn1Zf0PKG4nSis+n7xNIBqpwf3L/XoEbJvungIgpj8eDcBXwkJe8uf18fcjNeVeWlqY+gt Hj7OwNO2+SzuwiNJ7ewOE3TnaJbPMue2m0OnarV+BDcBZeno2h28+bi0evGkVVlxr1FJij9s= X-TMASE-XGENCLOUD: b596556d-1541-4545-94d5-0bd527f9830e-0-0-200-0 X-TM-Deliver-Signature: 4B75157F6560D3E40563D7BEB06BEF55 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=opensynergy.com; s=TM-DKIM-20210503141657; t=1650873629; bh=tFjc8XPTGr7ptgHpqlbtB+Y4n22YYUH5VxHiHOFhgPU=; l=1188; h=From:To:Date; b=Brn0EHieZ1OY7YT3SVeSllKo6cs6YIf2DGdnigqjgJcg2iVfb2DTN/vWMIHGowvlU FsEF7a9oO9ZKPZrbqMGYC5q2gbRMnjpH/Tf5guhKUzj8BpzGRY6AFSGrG+BiApSjKh CCbo6dZ0f3mOJGCpQyDx0ElOb6tGLwkZ3MIrNqFkVAD53A8vjZh9JNePq+405SZh5E cH/ZSZQgSUd69Y0gnJ1oLtCCbULmWJjqCabgG2FttLEBgHJ9yR9XXTwONOX1dtOLCg E2eaFQHCWwDm4A0tXhxoKX+UDZtJ9WBzCQXEaM5gVNxvM0Dul4fFExz9U+3+lFCtXC SADrDlPsyrF0A== List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 25 Apr 2022 19:26:13 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto/message/56868 Since splash screen is shown only on the first scanout, there is no need to allocate resources for next connectors. Signed-off-by: Vasyl Vavrychuk --- psplash-drm.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/psplash-drm.c b/psplash-drm.c index 2468cf1..5e56286 100644 --- a/psplash-drm.c +++ b/psplash-drm.c @@ -39,6 +39,8 @@ #include #include "psplash-drm.h" +#define MIN(a,b) ((a) < (b) ? (a) : (b)) + struct modeset_dev; static int modeset_find_crtc(int fd, drmModeRes *res, drmModeConnector *conn, struct modeset_dev *dev); @@ -196,8 +198,10 @@ static int modeset_prepare(int fd) return -errno; } - /* iterate all connectors */ - for (i = 0; i < res->count_connectors; ++i) { + /* ~iterate all connectors~ - Use first connector if present. It is + optimization related workaround since psplash supports drawing splash + screen on one scanout anyway. */ + for (i = 0; i < MIN(res->count_connectors, 1); ++i) { /* get information for each connector */ conn = drmModeGetConnector(fd, res->connectors[i]); if (!conn) { From patchwork Mon Apr 25 07:59:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasyl Vavrychuk X-Patchwork-Id: 7093 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91B1EC54F3F for ; Mon, 25 Apr 2022 19:26:13 +0000 (UTC) Received: from repost01.tmes.trendmicro.eu (repost01.tmes.trendmicro.eu [18.185.115.25]) by mx.groups.io with SMTP id smtpd.web12.26787.1650873656109728942 for ; Mon, 25 Apr 2022 01:00:56 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@opensynergy.com header.s=tm-dkim-20210503141657 header.b=oufhHCY0; spf=pass (domain: opensynergy.com, ip: 18.185.115.25, mailfrom: vasyl.vavrychuk@opensynergy.com) Received: from 104.47.14.54_.trendmicro.com (unknown [172.21.163.172]) by repost01.tmes.trendmicro.eu (Postfix) with SMTP id C43A4100004DB for ; Mon, 25 Apr 2022 08:00:54 +0000 (UTC) X-TM-MAIL-RECEIVED-TIME: 1650873625.276000 X-TM-MAIL-UUID: cd84c2d2-57cd-445d-9239-306cc861a885 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (unknown [104.47.14.54]) by repre01.tmes.trendmicro.eu (Trend Micro Email Security) with ESMTPS id 43AA81000030B for ; Mon, 25 Apr 2022 08:00:25 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d8dbu5o1p2boDZW4lSb1Dx3af4S9IfduTazhBkVThm/0Rp2G5vsW1PnNlPfLIEaJ7sfm/oYFKnuK2b0EXL0qivVo8dKE5umnBvI36klXPm5dkUusz4MNHF2npkJjmq+BYJLm2l6RxaszwzqNPUTizLitG+Fkl2k0TPn+MkIksGD3orqtexmru9UYt6YLpTdApJxTbDSBFraKV11X18NY9aI3phTD0jijKRZkgYyIp8oYnkL8BBEF0ZRIDhTQVE2Q2ZcMS36RTGoD008Tpj93sonJPy3uxtwBFvfawtwHv2sIU5N4ygAz6y/nDmLaO0nzSOSJCQ/QXT0XH+bjxcSu6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=8Dc55vEstd5PDC/UCDmMhloxg+xKgIo6OSQ8L/2fdDk=; b=f/91UTYIR52VJcQXOMiwRo7CrbmFh8eZZxjhdNWEksT0yPS0W+W8y7Y7oU4Dnw+uypyMy8XbcVzit3j6CquGxC0ZJW1n2rGbmLo/m/vju8FvyfrAh2xWjUkwwgAlSGvek2EWbJWbHGzPzfsiLO1QfjziX2eyU1qC2EY4Fn4jh2HN82eqbLH7tSTk73bJ9Ef+1wSXLEKm04cPIB4WOcAK0h8VuX9gnsIGqWkNmcNnuxeON80zS8LRnpDoTdHjpPaIKTdcSOjSoTMew3wBvGKsCheTF811ntNdl2AzTxQWFFbifLRtCcxvKaAenrexKbil8ctNffQnDNxS7T97MEu0pg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 217.66.60.4) smtp.rcpttodomain=lists.yoctoproject.org smtp.mailfrom=opensynergy.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=opensynergy.com; dkim=none (message not signed); arc=none X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 217.66.60.4) smtp.mailfrom=opensynergy.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=opensynergy.com; Received-SPF: Pass (protection.outlook.com: domain of opensynergy.com designates 217.66.60.4 as permitted sender) receiver=protection.outlook.com; client-ip=217.66.60.4; helo=SR-MAIL-03.open-synergy.com; From: Vasyl Vavrychuk To: yocto@lists.yoctoproject.org Cc: Vasyl Vavrychuk Subject: [psplash][RFC PATCH 14/14] psplash-drm.c: Implement double buffering Date: Mon, 25 Apr 2022 10:59:54 +0300 Message-Id: <20220425075954.10427-15-vasyl.vavrychuk@opensynergy.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220425075954.10427-1-vasyl.vavrychuk@opensynergy.com> References: <20220425075954.10427-1-vasyl.vavrychuk@opensynergy.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8c3c4d2f-366f-4918-fd0b-08da2691a687 X-MS-TrafficTypeDiagnostic: DU2PR04MB9018:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 809FLHsZe6qUSvSLjHVNoVouFLTK4ov9PYvNPxybAcB0ATJG08vDvq6nvjphfVALE5Z5hlc/11KjyV2gTRFRK/hM6kZcMqB/mVcl+JWY7uQCW6NwswnBumWj8qFKprbRtxiDZRw3gcWVX2hp8Nb03PdqJ35jtvgbw7sLuiLDhtEoKkeQM652G9uihTSVXreyfDDU83cnpq6BbQUp9api29jkWqM3uPaux32ufLzB6T51S34LQshmOyfElLEjFQaocCDQu/jJFm3w6Q13IiC1b8tVKmZoyBDgrG8jaM4WU9cu7jXg7R5HF9kXsdhhMUKxvQa+gDgpj52qmpR5VikHmtiTIiXcbetd+/+Zv+cXp3Dq5vb/qVzj8BlIzSeHiCh0bKvJIlCm3694dPgaJXnGejGuvmONueVkkGypUS1kc3DxokD9yC1/S8dOWh3nANjWmIe01fURQGImvwhgjG2o6Lzgbc5CvomBQjio/r5/hwEiPeEPFo7WwAzWsqtEriYbLmzsgzCnnm3IlATCbzB7g9HMU7njr9qnU4nxqsuZAmj3x7B1XfcLy4Yc50d7n/kEx2Y951kx1cCp2rhqnbLqPS808Q503jMdMQsBLzRUXsgBbP1zWtuCXarYJOnpEbntjeuZESGUQ2dP3Aowg3J6G9qaxjQFVb6zR3Ddkl1MDjKI0CvBJj3DeVBrp7SArbuTCJEWvstUS3bvub8ONSFpRYTNSO+wkJxGv6NLoj0hhvCnEFR2PFGNxqKXNFTE4d8R4Pkri+z1hQDS3pZuNKZKxg9CvHJaC3qG1y6yKhGrTZg= X-Forefront-Antispam-Report: CIP:217.66.60.4;CTRY:DE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SR-MAIL-03.open-synergy.com;PTR:mx1.opensynergy.com;CAT:NONE;SFS:(13230001)(396003)(39830400003)(346002)(136003)(376002)(46966006)(36840700001)(4326008)(1076003)(336012)(70586007)(186003)(508600001)(2616005)(107886003)(70206006)(8676002)(47076005)(26005)(966005)(316002)(36756003)(42186006)(81166007)(6916009)(36860700001)(2906002)(82310400005)(40480700001)(86362001)(8936002)(44832011)(30864003)(5660300002)(83380400001)(334744004);DIR:OUT;SFP:1102; X-OriginatorOrg: opensynergy.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2022 08:00:23.1452 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8c3c4d2f-366f-4918-fd0b-08da2691a687 X-MS-Exchange-CrossTenant-Id: 800fae25-9b1b-4edc-993d-c939c4e84a64 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=800fae25-9b1b-4edc-993d-c939c4e84a64;Ip=[217.66.60.4];Helo=[SR-MAIL-03.open-synergy.com] X-MS-Exchange-CrossTenant-AuthSource: VI1EUR05FT008.eop-eur05.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB9018 X-TM-AS-ERS: 104.47.14.54-0.0.0.0 X-TMASE-Version: StarCloud-1.3-8.8.1001-26854.006 X-TMASE-Result: 10--6.860500-4.000000 X-TMASE-MatchedRID: R7L2HT/hrj82UEKHDN0wzE7nLUqYrlslFIuBIWrdOePfUZT83lbkEB/a 4gy0uyn1Zf0PKG4nSisaXFa2Hul38Aw8Nmue9wz3EVuC0eNRYvJ955Y1Xr69w57fzNec2D1D+/K qneiC8jbknJx2koMJ78gmG/32DThg+jikdSWVZvOGOUGPCmibU1kN0eJOT05wLEzDQUyQGVkQpB sX6bvecfG+qK1HFo4elnuvuutfYjRFqOm7OcUhtxIRh9wkXSlFlwT0XposETVr83Ad0EHF0RkdJ i18bDYpcVQBsXJUGz5pM4uQJ+eFBmptPhjDCRugPMcAlOC0qrCd2Wz0X3OaLf2KWAuA/s+whVit winLxPz9dU4/wVV+opEaMREJDt1RdR/G8OvKIg8LbigRnpKlKSPzRlrdFGDw2bMh+MiMuuS7bkR V0YmjBbJ3vuyiY7CXsn50u+gkSlbGZ5s4jRI67w== X-TMASE-XGENCLOUD: 41888092-cea1-4b86-a564-c71377ebe712-0-0-200-0 X-TM-Deliver-Signature: 3161BD8F64FAA02ED5B05E072C4B367D DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=opensynergy.com; s=TM-DKIM-20210503141657; t=1650873654; bh=vwYcJ5+LhgT74pAb/maziCXwr9PyXRAIm8859PEOx7U=; l=10852; h=From:To:Date; b=oufhHCY0hf5/Kv76QF+UxsvhfxmoM9nIJ1jaO2UzVS/ct1dQUBzscexT6nWK3Km+9 nPm4GehyZF9fx+qcI/9Ot702Tow3pJ3lYGEwvl1dX0wIzRKNkEviq3fHCMpMwVQ32q NMtyNdiWiq9lyQw1qbeu7lWnX+HhQs3WaoSCELcyJhABax/zjM9gvPp7mxM0rvzkSP rrJ+kEbrpLKnNsoKZ8YT6Z3T6NDDu1rRFh+7hh5G7NhjcJxspxGiFlIWDzgnikXpyu zUh451nQ/J4aLJJErae1f8csAcw+i9+6BjU6MJDhNarQQdawf0JhBBwMQstp4Gupcr V+ZQVedTiUCxw== List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 25 Apr 2022 19:26:13 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto/message/56873 Based on https://github.com/dvdhrm/docs/blob/master/drm-howto/modeset-double-buffered.c Signed-off-by: Vasyl Vavrychuk --- psplash-drm.c | 176 +++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 140 insertions(+), 36 deletions(-) diff --git a/psplash-drm.c b/psplash-drm.c index 5e56286..fcb7507 100644 --- a/psplash-drm.c +++ b/psplash-drm.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -41,10 +42,12 @@ #define MIN(a,b) ((a) < (b) ? (a) : (b)) +struct modeset_buf; struct modeset_dev; static int modeset_find_crtc(int fd, drmModeRes *res, drmModeConnector *conn, struct modeset_dev *dev); -static int modeset_create_fb(int fd, struct modeset_dev *dev); +static int modeset_create_fb(int fd, struct modeset_buf *buf); +static void modeset_destroy_fb(int fd, struct modeset_buf *buf); static int modeset_setup_dev(int fd, drmModeRes *res, drmModeConnector *conn, struct modeset_dev *dev); static int modeset_open(int *out, const char *node); @@ -144,18 +147,45 @@ static int modeset_open(int *out, const char *node) * } */ -struct modeset_dev { - struct modeset_dev *next; +/* + * Previously, we used the modeset_dev objects to hold buffer informations, too. + * Technically, we could have split them but avoided this to make the + * example simpler. + * However, in this example we need 2 buffers. One back buffer and one front + * buffer. So we introduce a new structure modeset_buf which contains everything + * related to a single buffer. Each device now gets an array of two of these + * buffers. + * Each buffer consists of width, height, stride, size, handle, map and fb-id. + * They have the same meaning as before. + * + * Each device also gets a new integer field: front_buf. This field contains the + * index of the buffer that is currently used as front buffer / scanout buffer. + * In our example it can be 0 or 1. We flip it by using XOR: + * dev->front_buf ^= dev->front_buf + * + * Everything else stays the same. + */ +struct modeset_buf { uint32_t width; uint32_t height; uint32_t stride; uint32_t size; uint32_t handle; void *map; + uint32_t fb; +}; + +struct modeset_dev { + struct modeset_dev *next; + + uint32_t width; + uint32_t height; + + unsigned int front_buf; + struct modeset_buf bufs[2]; drmModeModeInfo mode; - uint32_t fb; uint32_t conn; uint32_t crtc; drmModeCrtc *saved_crtc; @@ -292,10 +322,15 @@ static int modeset_setup_dev(int fd, drmModeRes *res, drmModeConnector *conn, return -EFAULT; } - /* copy the mode information into our device structure */ + /* copy the mode information into our device structure and into both + * buffers */ memcpy(&dev->mode, &conn->modes[0], sizeof(dev->mode)); dev->width = conn->modes[0].hdisplay; dev->height = conn->modes[0].vdisplay; + dev->bufs[0].width = dev->width; + dev->bufs[0].height = dev->height; + dev->bufs[1].width = dev->width; + dev->bufs[1].height = dev->height; fprintf(stderr, "mode for connector %u is %ux%u\n", conn->connector_id, dev->width, dev->height); @@ -307,14 +342,30 @@ static int modeset_setup_dev(int fd, drmModeRes *res, drmModeConnector *conn, return ret; } - /* create a framebuffer for this CRTC */ - ret = modeset_create_fb(fd, dev); + /* create framebuffer #1 for this CRTC */ + ret = modeset_create_fb(fd, &dev->bufs[0]); if (ret) { fprintf(stderr, "cannot create framebuffer for connector %u\n", conn->connector_id); return ret; } + /* create framebuffer #2 for this CRTC */ + ret = modeset_create_fb(fd, &dev->bufs[1]); + if (ret) { + fprintf(stderr, "cannot create framebuffer for connector %u\n", + conn->connector_id); + modeset_destroy_fb(fd, &dev->bufs[0]); + return ret; + } + + if (dev->bufs[0].size != dev->bufs[1].size) { + fprintf(stderr, "front buffer size %" PRIu32 " does not match " + "back buffer size %" PRIu32 "\n", + dev->bufs[0].size, dev->bufs[1].size); + return -1; + } + return 0; } @@ -441,7 +492,7 @@ static int modeset_find_crtc(int fd, drmModeRes *res, drmModeConnector *conn, * memory directly via the dev->map memory map. */ -static int modeset_create_fb(int fd, struct modeset_dev *dev) +static int modeset_create_fb(int fd, struct modeset_buf *buf) { struct drm_mode_create_dumb creq; struct drm_mode_destroy_dumb dreq; @@ -450,8 +501,8 @@ static int modeset_create_fb(int fd, struct modeset_dev *dev) /* create dumb buffer */ memset(&creq, 0, sizeof(creq)); - creq.width = dev->width; - creq.height = dev->height; + creq.width = buf->width; + creq.height = buf->height; creq.bpp = 32; ret = drmIoctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &creq); if (ret < 0) { @@ -459,13 +510,13 @@ static int modeset_create_fb(int fd, struct modeset_dev *dev) errno); return -errno; } - dev->stride = creq.pitch; - dev->size = creq.size; - dev->handle = creq.handle; + buf->stride = creq.pitch; + buf->size = creq.size; + buf->handle = creq.handle; /* create framebuffer object for the dumb-buffer */ - ret = drmModeAddFB(fd, dev->width, dev->height, 24, 32, dev->stride, - dev->handle, &dev->fb); + ret = drmModeAddFB(fd, buf->width, buf->height, 24, 32, buf->stride, + buf->handle, &buf->fb); if (ret) { fprintf(stderr, "cannot create framebuffer (%d): %m\n", errno); @@ -475,7 +526,7 @@ static int modeset_create_fb(int fd, struct modeset_dev *dev) /* prepare buffer for memory mapping */ memset(&mreq, 0, sizeof(mreq)); - mreq.handle = dev->handle; + mreq.handle = buf->handle; ret = drmIoctl(fd, DRM_IOCTL_MODE_MAP_DUMB, &mreq); if (ret) { fprintf(stderr, "cannot map dumb buffer (%d): %m\n", @@ -485,9 +536,9 @@ static int modeset_create_fb(int fd, struct modeset_dev *dev) } /* perform actual memory mapping */ - dev->map = mmap(0, dev->size, PROT_READ | PROT_WRITE, MAP_SHARED, + buf->map = mmap(0, buf->size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, mreq.offset); - if (dev->map == MAP_FAILED) { + if (buf->map == MAP_FAILED) { fprintf(stderr, "cannot mmap dumb buffer (%d): %m\n", errno); ret = -errno; @@ -495,23 +546,73 @@ static int modeset_create_fb(int fd, struct modeset_dev *dev) } /* clear the framebuffer to 0 */ - memset(dev->map, 0, dev->size); + memset(buf->map, 0, buf->size); return 0; err_fb: - drmModeRmFB(fd, dev->fb); + drmModeRmFB(fd, buf->fb); err_destroy: memset(&dreq, 0, sizeof(dreq)); - dreq.handle = dev->handle; + dreq.handle = buf->handle; drmIoctl(fd, DRM_IOCTL_MODE_DESTROY_DUMB, &dreq); return ret; } +/* + * modeset_destroy_fb() is a new function. It does exactly the reverse of + * modeset_create_fb() and destroys a single framebuffer. The modeset.c example + * used to do this directly in modeset_cleanup(). + * We simply unmap the buffer, remove the drm-FB and destroy the memory buffer. + */ + +static void modeset_destroy_fb(int fd, struct modeset_buf *buf) +{ + struct drm_mode_destroy_dumb dreq; + + /* unmap buffer */ + munmap(buf->map, buf->size); + + /* delete framebuffer */ + drmModeRmFB(fd, buf->fb); + + /* delete dumb buffer */ + memset(&dreq, 0, sizeof(dreq)); + dreq.handle = buf->handle; + drmIoctl(fd, DRM_IOCTL_MODE_DESTROY_DUMB, &dreq); +} + static void psplash_drm_flip(PSplashCanvas *canvas, int sync) { - (void)canvas; + PSplashDRM *drm = canvas->priv; + struct modeset_buf *buf; + int ret; + (void)sync; + + /* pick a back buffer */ + buf = &modeset_list->bufs[modeset_list->front_buf ^ 1]; + + /* set back buffer as a front buffer */ + ret = drmModeSetCrtc(drm->fd, modeset_list->crtc, buf->fb, 0, 0, + &modeset_list->conn, 1, &modeset_list->mode); + if (ret) { + fprintf(stderr, "cannot flip CRTC for connector %u (%d): %m\n", + modeset_list->conn, errno); + return; + } + + /* update front buffer index */ + modeset_list->front_buf ^= 1; + + /* update back buffer pointer */ + drm->canvas.data = modeset_list->bufs[modeset_list->front_buf ^ 1].map; + + /* Sync new front to new back when requested */ + if (sync) + memcpy(modeset_list->bufs[modeset_list->front_buf ^ 1].map, + modeset_list->bufs[modeset_list->front_buf].map, + modeset_list->bufs[0].size); } /* @@ -555,6 +656,7 @@ PSplashDRM* psplash_drm_new(int angle, int dev_id) int ret; char card[] = "/dev/dri/card0"; struct modeset_dev *iter; + struct modeset_buf *buf; if ((drm = malloc(sizeof(*drm))) == NULL) { perror("malloc"); @@ -583,18 +685,28 @@ PSplashDRM* psplash_drm_new(int angle, int dev_id) /* perform actual modesetting on each found connector+CRTC */ for (iter = modeset_list; iter; iter = iter->next) { iter->saved_crtc = drmModeGetCrtc(drm->fd, iter->crtc); - ret = drmModeSetCrtc(drm->fd, iter->crtc, iter->fb, 0, 0, + buf = &iter->bufs[iter->front_buf]; + ret = drmModeSetCrtc(drm->fd, iter->crtc, buf->fb, 0, 0, &iter->conn, 1, &iter->mode); if (ret) fprintf(stderr, "cannot set CRTC for connector %u (%d): %m\n", iter->conn, errno); } - drm->canvas.data = modeset_list->map; + drm->canvas.data = modeset_list->bufs[modeset_list->front_buf ^ 1].map; drm->canvas.width = modeset_list->width; drm->canvas.height = modeset_list->height; drm->canvas.bpp = 32; - drm->canvas.stride = modeset_list->stride; + + if (modeset_list->bufs[0].stride != modeset_list->bufs[1].stride) { + fprintf(stderr, "front buffer stride %" PRIu32 " does not match" + " back buffer stride %" PRIu32 "\n", + modeset_list->bufs[0].stride, + modeset_list->bufs[1].stride); + goto error; + } + drm->canvas.stride = modeset_list->bufs[0].stride; + drm->canvas.angle = angle; drm->canvas.rgbmode = RGB888; @@ -614,7 +726,6 @@ error: void psplash_drm_destroy(PSplashDRM *drm) { struct modeset_dev *iter; - struct drm_mode_destroy_dumb dreq; if (!drm) return; @@ -635,16 +746,9 @@ void psplash_drm_destroy(PSplashDRM *drm) &iter->saved_crtc->mode); drmModeFreeCrtc(iter->saved_crtc); - /* unmap buffer */ - munmap(iter->map, iter->size); - - /* delete framebuffer */ - drmModeRmFB(drm->fd, iter->fb); - - /* delete dumb buffer */ - memset(&dreq, 0, sizeof(dreq)); - dreq.handle = iter->handle; - drmIoctl(drm->fd, DRM_IOCTL_MODE_DESTROY_DUMB, &dreq); + /* destroy framebuffers */ + modeset_destroy_fb(drm->fd, &iter->bufs[1]); + modeset_destroy_fb(drm->fd, &iter->bufs[0]); /* free allocated memory */ free(iter);