From patchwork Wed Dec 13 19:47:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: 'Max Staudt X-Patchwork-Id: 10110807 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 806B560327 for ; Wed, 13 Dec 2017 19:53:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6913F2953B for ; Wed, 13 Dec 2017 19:53:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6781C29649; Wed, 13 Dec 2017 19:53:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3E9A129CFC for ; Wed, 13 Dec 2017 19:51:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753831AbdLMTsp (ORCPT ); Wed, 13 Dec 2017 14:48:45 -0500 Received: from mx2.suse.de ([195.135.220.15]:53738 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753552AbdLMTso (ORCPT ); Wed, 13 Dec 2017 14:48:44 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 65E09AEA8; Wed, 13 Dec 2017 19:48:42 +0000 (UTC) From: Max Staudt To: b.zolnierkie@samsung.com, linux-fbdev@vger.kernel.org Cc: mstaudt@suse.de, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, tiwai@suse.com, oneukum@suse.com, msrb@suse.com, sndirsch@suse.com, michal@markovi.net, philm@manjaro.org, bernhard.rosenkranzer@linaro.org Subject: [RFC PATCH v2 04/13] bootsplash: Add corner positioning Date: Wed, 13 Dec 2017 20:47:46 +0100 Message-Id: <20171213194755.3409-5-mstaudt@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20171213194755.3409-1-mstaudt@suse.de> References: <20171213194755.3409-1-mstaudt@suse.de> Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This allows showing multiple logos, each in its own position, relative to the eight screen corners. Signed-off-by: Max Staudt --- drivers/video/fbdev/core/bootsplash_render.c | 136 ++++++++++++++++++++++++++- include/uapi/linux/bootsplash_file.h | 45 ++++++++- 2 files changed, 178 insertions(+), 3 deletions(-) diff --git a/drivers/video/fbdev/core/bootsplash_render.c b/drivers/video/fbdev/core/bootsplash_render.c index 8c09c306ff67..07e3a4eab811 100644 --- a/drivers/video/fbdev/core/bootsplash_render.c +++ b/drivers/video/fbdev/core/bootsplash_render.c @@ -155,6 +155,7 @@ void bootsplash_do_render_pictures(struct fb_info *info, for (i = 0; i < fp->header->num_pics; i++) { struct splash_blob_priv *bp; struct splash_pic_priv *pp = &fp->pics[i]; + const struct splash_pic_header *ph = pp->pic_header; long dst_xoff, dst_yoff; if (pp->blobs_loaded < 1) @@ -165,8 +166,139 @@ void bootsplash_do_render_pictures(struct fb_info *info, if (!bp || bp->blob_header->type != 0) continue; - dst_xoff = (info->var.xres - pp->pic_header->width) / 2; - dst_yoff = (info->var.yres - pp->pic_header->height) / 2; + switch (ph->position) { + case SPLASH_POS_FLAG_CORNER | SPLASH_CORNER_TOP_LEFT: + dst_xoff = 0; + dst_yoff = 0; + + dst_xoff += ph->position_offset; + dst_yoff += ph->position_offset; + break; + case SPLASH_POS_FLAG_CORNER | SPLASH_CORNER_TOP: + dst_xoff = info->var.xres - pp->pic_header->width; + dst_xoff /= 2; + dst_yoff = 0; + + dst_yoff += ph->position_offset; + break; + case SPLASH_POS_FLAG_CORNER | SPLASH_CORNER_TOP_RIGHT: + dst_xoff = info->var.xres - pp->pic_header->width; + dst_yoff = 0; + + dst_xoff -= ph->position_offset; + dst_yoff += ph->position_offset; + break; + case SPLASH_POS_FLAG_CORNER | SPLASH_CORNER_RIGHT: + dst_xoff = info->var.xres - pp->pic_header->width; + dst_yoff = info->var.yres - pp->pic_header->height; + dst_yoff /= 2; + + dst_xoff -= ph->position_offset; + break; + case SPLASH_POS_FLAG_CORNER | SPLASH_CORNER_BOTTOM_RIGHT: + dst_xoff = info->var.xres - pp->pic_header->width; + dst_yoff = info->var.yres - pp->pic_header->height; + + dst_xoff -= ph->position_offset; + dst_yoff -= ph->position_offset; + break; + case SPLASH_POS_FLAG_CORNER | SPLASH_CORNER_BOTTOM: + dst_xoff = info->var.xres - pp->pic_header->width; + dst_xoff /= 2; + dst_yoff = info->var.yres - pp->pic_header->height; + + dst_yoff -= ph->position_offset; + break; + case SPLASH_POS_FLAG_CORNER | SPLASH_CORNER_BOTTOM_LEFT: + dst_xoff = 0 + ph->position_offset; + dst_yoff = info->var.yres - pp->pic_header->height + - ph->position_offset; + break; + case SPLASH_POS_FLAG_CORNER | SPLASH_CORNER_LEFT: + dst_xoff = 0; + dst_yoff = info->var.yres - pp->pic_header->height; + dst_yoff /= 2; + + dst_xoff += ph->position_offset; + break; + + case SPLASH_CORNER_TOP_LEFT: + dst_xoff = info->var.xres - pp->pic_header->width; + dst_xoff /= 2; + dst_yoff = info->var.yres - pp->pic_header->height; + dst_yoff /= 2; + + dst_xoff -= ph->position_offset; + dst_yoff -= ph->position_offset; + break; + case SPLASH_CORNER_TOP: + dst_xoff = info->var.xres - pp->pic_header->width; + dst_xoff /= 2; + dst_yoff = info->var.yres - pp->pic_header->height; + dst_yoff /= 2; + + dst_yoff -= ph->position_offset; + break; + case SPLASH_CORNER_TOP_RIGHT: + dst_xoff = info->var.xres - pp->pic_header->width; + dst_xoff /= 2; + dst_yoff = info->var.yres - pp->pic_header->height; + dst_yoff /= 2; + + dst_xoff += ph->position_offset; + dst_yoff -= ph->position_offset; + break; + case SPLASH_CORNER_RIGHT: + dst_xoff = info->var.xres - pp->pic_header->width; + dst_xoff /= 2; + dst_yoff = info->var.yres - pp->pic_header->height; + dst_yoff /= 2; + + dst_xoff += ph->position_offset; + break; + case SPLASH_CORNER_BOTTOM_RIGHT: + dst_xoff = info->var.xres - pp->pic_header->width; + dst_xoff /= 2; + dst_yoff = info->var.yres - pp->pic_header->height; + dst_yoff /= 2; + + dst_xoff += ph->position_offset; + dst_yoff += ph->position_offset; + break; + case SPLASH_CORNER_BOTTOM: + dst_xoff = info->var.xres - pp->pic_header->width; + dst_xoff /= 2; + dst_yoff = info->var.yres - pp->pic_header->height; + dst_yoff /= 2; + + dst_yoff += ph->position_offset; + break; + case SPLASH_CORNER_BOTTOM_LEFT: + dst_xoff = info->var.xres - pp->pic_header->width; + dst_xoff /= 2; + dst_yoff = info->var.yres - pp->pic_header->height; + dst_yoff /= 2; + + dst_xoff -= ph->position_offset; + dst_yoff += ph->position_offset; + break; + case SPLASH_CORNER_LEFT: + dst_xoff = info->var.xres - pp->pic_header->width; + dst_xoff /= 2; + dst_yoff = info->var.yres - pp->pic_header->height; + dst_yoff /= 2; + + dst_xoff -= ph->position_offset; + break; + + default: + /* As a fallback, center the picture. */ + dst_xoff = info->var.xres - pp->pic_header->width; + dst_xoff /= 2; + dst_yoff = info->var.yres - pp->pic_header->height; + dst_yoff /= 2; + break; + } if (dst_xoff < 0 || dst_yoff < 0 diff --git a/include/uapi/linux/bootsplash_file.h b/include/uapi/linux/bootsplash_file.h index 89dc9cca8f0c..71cedcc68933 100644 --- a/include/uapi/linux/bootsplash_file.h +++ b/include/uapi/linux/bootsplash_file.h @@ -91,7 +91,32 @@ struct splash_pic_header { */ uint8_t num_blobs; - uint8_t padding[27]; + /* + * Corner to move the picture to / from. + * 0x00 - Top left + * 0x01 - Top + * 0x02 - Top right + * 0x03 - Right + * 0x04 - Bottom right + * 0x05 - Bottom + * 0x06 - Bottom left + * 0x07 - Left + * + * Flags: + * 0x10 - Calculate offset from the corner towards the center, + * rather than from the center towards the corner + */ + uint8_t position; + + /* + * Pixel offset from the selected position. + * Example: If the picture is in the top right corner, it will + * be placed position_offset pixels from the top and + * position_offset pixels from the right margin. + */ + uint16_t position_offset; + + uint8_t padding[24]; } __attribute__((__packed__)); @@ -115,4 +140,22 @@ struct splash_blob_header { uint8_t padding[9]; } __attribute__((__packed__)); + + + +/* + * Enums for on-disk types + */ +enum splash_position { + SPLASH_CORNER_TOP_LEFT = 0, + SPLASH_CORNER_TOP = 1, + SPLASH_CORNER_TOP_RIGHT = 2, + SPLASH_CORNER_RIGHT = 3, + SPLASH_CORNER_BOTTOM_RIGHT = 4, + SPLASH_CORNER_BOTTOM = 5, + SPLASH_CORNER_BOTTOM_LEFT = 6, + SPLASH_CORNER_LEFT = 7, + SPLASH_POS_FLAG_CORNER = 0x10, +}; + #endif