From patchwork Mon Feb 26 15:21:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Gladkov X-Patchwork-Id: 206759 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2171283dyb; Mon, 26 Feb 2024 08:03:48 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVDu3WhlVQCh+D4W91QzOeRc+SogCXFutKFOsGAWUELkRJfvwMfmAe11lTF/CgdEYVSA+jK7+dCAZ2JWyqx0Nw63k4gIw== X-Google-Smtp-Source: AGHT+IHiFiKkBkoGkl+rtAb0dUM6W7MgpMl6GT5fPQzT9lFnvRddZ9P9Zh3NNypQEH3oWCZRe5L2 X-Received: by 2002:a17:90a:780f:b0:299:951f:e7de with SMTP id w15-20020a17090a780f00b00299951fe7demr6359922pjk.14.1708963428286; Mon, 26 Feb 2024 08:03:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708963428; cv=pass; d=google.com; s=arc-20160816; b=bNTshle+u79LcQxzHCJx08LY7ytm1lTRyZ4McKMxUWRvl1dzJ1jkwH5odoJm3NP9Dm 3jvemV3+wjj2VL+kDB8789jt6BkqiLY13KMK7sSAfs8cjK/saW+WnPxlWmAJ2a0AYRZC TckFiV1jyCRIshxcXiov3DMexOliePH/P+B8j5O1YJuCiqiw/uDcFjRqFp7KPSZdcM19 940WYtFM8s+fx9KR25BkbPcJtXWD7EuHsIjOroVnS/l+uEZLOPVUa92s6B3mrY7lnUuX 9nPlLZ/mXqbyukFeUGtBmhpw52TLjgVt7oKqjUYRN3RfqDf/i5PXiPk6/VhHGfVw966t 63+w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=vRpPc10ppne077tjCjcdxPUsAtSf5jqT1q37hr7rLEg=; fh=+sjJkTnuceKV/39ogbp2WrGgLtnGuaoEzUs1VQcMbqE=; b=JeC2RtAOvgoHybujTrb11WcYhGZAg5rSxW27wS20KsaRY212jAbB/ssB5qNpNYrId6 VLlXMuJ1OopD4QVSnvyi0J6P2L0Oafc67OpvFCZAFbTvcyfb/zAsnvV/awDDOwxuCfw8 lDGFDB1gBHLGgaIGLqlOSY/dORsY/3FkuxK/+pu3NYlL1zEKhL3PNjDvpmnPcygyl+By 18IesT8/DsXcEbViRBMjnyEM3wB6YFqaiLaEd7/JgBTjU4O9SoGxmUjHREZduBjFomfd oLMP72xDtHx+WyN4OFDV5Dkxq6G5hbj5Om0+vIChCtwyqHLclJyhwCB0xNJFfDG7Dral LzSQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-81791-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81791-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id ee13-20020a17090afc4d00b0029aad5991a9si3109680pjb.111.2024.02.26.08.03.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 08:03:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81791-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-81791-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81791-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 32C85B328D7 for ; Mon, 26 Feb 2024 15:25:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0644D12EBC4; Mon, 26 Feb 2024 15:22:49 +0000 (UTC) Received: from us-smtp-delivery-44.mimecast.com (us-smtp-delivery-44.mimecast.com [205.139.111.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F063112C812 for ; Mon, 26 Feb 2024 15:22:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.139.111.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708960967; cv=none; b=KD5PHcJN2qmHt79+s+2LV7T6q7NWyfZiLd8zIP0unQ8rQAQZbyzQznUrmuz2CRyUxLThkcbTSDHJ7P/+pmdDSCxRijzQZvieXX9jVPlAZmhPqc3oTw4RA7X5OrpvLbm7Oq+r13jTRjdf7N/y1jdQsUO3ivNXrSAhuBAX/uxx5So= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708960967; c=relaxed/simple; bh=kmBEBhIPZ3K6yo8dFqH+CwKILdo/XwZlWONCFjWvj5Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SeYBM+7LvNqvu7nzGYBZj3G3T8o3RMvtQ8ZbjDHgduZ15JIT0LCuPcJLoIBU9TG5mLaQaDv0mnAujD99GoG7XJmowhLA1DZ2ALawqaWMgwAfB8OBiCBCvJuTGwMM0OUVlPsn+9TRddpHIKboQHWlL04wkoE8CYN1dERONuIUXVA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=fail smtp.mailfrom=kernel.org; arc=none smtp.client-ip=205.139.111.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=kernel.org Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-575-LNEoIRY9OxCisOBL_DgNZg-1; Mon, 26 Feb 2024 10:21:25 -0500 X-MC-Unique: LNEoIRY9OxCisOBL_DgNZg-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C09591097B05; Mon, 26 Feb 2024 15:21:24 +0000 (UTC) Received: from gentoo.redhat.com (unknown [10.45.224.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0C3DB492BE2; Mon, 26 Feb 2024 15:21:23 +0000 (UTC) From: Alexey Gladkov To: LKML , Greg Kroah-Hartman , Jiri Slaby Cc: linux-api@vger.kernel.org Subject: [RFC PATCH v2 3/5] sticon: Allow to get max font width and height Date: Mon, 26 Feb 2024 16:21:12 +0100 Message-ID: <07c0cb7f0c175460561957190e48a6e01a74a676.1708960303.git.legion@kernel.org> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790981687794479761 X-GMAIL-MSGID: 1791978035331166358 Signed-off-by: Alexey Gladkov --- drivers/video/console/sticon.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/video/console/sticon.c b/drivers/video/console/sticon.c index 992a4fa431aa..d32ca458eb77 100644 --- a/drivers/video/console/sticon.c +++ b/drivers/video/console/sticon.c @@ -56,6 +56,11 @@ #define BLANK 0 static int vga_is_gfx; +#define STICON_MIN_FONT_WIDTH 6 +#define STICON_MIN_FONT_HEIGHT 6 +#define STICON_MAX_FONT_WIDTH 32 +#define STICON_MAX_FONT_HEIGHT 32 + #define STI_DEF_FONT sticon_sti->font /* borrowed from fbcon.c */ @@ -180,8 +185,10 @@ static int sticon_set_font(struct vc_data *vc, struct console_font *op, struct sti_cooked_font *cooked_font; unsigned char *data = op->data, *p; - if ((w < 6) || (h < 6) || (w > 32) || (h > 32) || (vpitch != 32) - || (op->charcount != 256 && op->charcount != 512)) + if (!in_range(w, STICON_MIN_FONT_WIDTH, STICON_MAX_FONT_WIDTH) || + !in_range(h, STICON_MIN_FONT_HEIGHT, STICON_MAX_FONT_HEIGHT) || + (vpitch != 32) || + (op->charcount != 256 && op->charcount != 512)) return -EINVAL; pitch = ALIGN(w, 8) / 8; bpc = pitch * h; @@ -273,6 +280,19 @@ static int sticon_font_set(struct vc_data *vc, struct console_font *font, return sticon_set_font(vc, font, vpitch); } +static int sticon_font_info(struct vc_data *vc, struct console_font_info *info) +{ + info->min_width = STICON_MIN_FONT_WIDTH; + info->min_height = STICON_MIN_FONT_HEIGHT; + + info->max_width = STICON_MAX_FONT_WIDTH; + info->max_height = STICON_MAX_FONT_HEIGHT; + + info->flags = KD_FONT_INFO_FLAG_LOW_SIZE | KD_FONT_INFO_FLAG_HIGH_SIZE; + + return 0; +} + static void sticon_init(struct vc_data *c, int init) { struct sti_struct *sti = sticon_sti; @@ -371,6 +391,7 @@ static const struct consw sti_con = { .con_scroll = sticon_scroll, .con_switch = sticon_switch, .con_blank = sticon_blank, + .con_font_info = sticon_font_info, .con_font_set = sticon_font_set, .con_font_default = sticon_font_default, .con_build_attr = sticon_build_attr,