Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1399676rbb; Mon, 26 Feb 2024 08:06:46 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWavdAhHNiwEmId+VDkwPmK+HRPMhOUE9cI7GbRNBJUw5c+FDtQ/MifT2px6yu3eeCseEP9pWdun5EcMVu9sCZ5/xfI9q3KQjkMlEBB3w== X-Google-Smtp-Source: AGHT+IEMWn1F9WzpTlmTTsAKn0ZL9LEKqGp/Azue79HTo7g+i1ynRqe4P57Midku49LJ4fqg/F10 X-Received: by 2002:a17:902:f682:b0:1dc:26a1:d1da with SMTP id l2-20020a170902f68200b001dc26a1d1damr10965821plg.13.1708963606237; Mon, 26 Feb 2024 08:06:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708963606; cv=pass; d=google.com; s=arc-20160816; b=kN7fz6rF/QOMLQ23Rb24Pja6m5FPRoKB1dNAn2fZOb3ABmvmDXvfli/cblYWdaYGdK 291L3a4Nf8tbYK3q4gS21V0JlgUk2dW2elu1gHMqw6obKfQ7koEC8LrEHp626zajZyp8 TeAtfPQsIZmWMx3bIl1SWv5VvaMB07rD7phld80i1cTCkWezaQetzfEvcH1Nec4y95+i vyy8Bh8uDySmyvmJktGS9qv3BVV//XdYeGFmdpjv0cQY7vbg3T8ACyrpR/An/ueVrUK0 lDzlcsvXDNluR3+eqcggfcXzrh0JIYtzZt8y9NpPj8h4E755MpIGQx+RNW+w2xerQ8XF ZSBg== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81791-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d2-20020a170902cec200b001dca6272e21si1577196plg.36.2024.02.26.08.06.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 08:06:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81791-linux.lists.archive=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-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81791-linux.lists.archive=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 7C3A3B3986D for ; Mon, 26 Feb 2024 15:25:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DA0B312C819; Mon, 26 Feb 2024 15:22:47 +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 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 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, -- 2.44.0