if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &dev))
return CMD_RET_FAILURE;
- font_name = vidconsole_get_font_size(dev, &size);
+ ret = vidconsole_get_font_size(dev, &font_name, &size);
+ if (ret) {
+ printf("Failed (error %d)\n", ret);
+ return CMD_RET_FAILURE;
+ }
size = dectoul(argv[1], NULL);
return 0;
}
-const char *vidconsole_get_font_size(struct udevice *dev, uint *sizep)
+const char *console_truetype_get_font_size(struct udevice *dev, uint *sizep)
{
struct console_tt_priv *priv = dev_get_priv(dev);
struct console_tt_metrics *met = priv->cur_met;
.backspace = console_truetype_backspace,
.entry_start = console_truetype_entry_start,
.get_font = console_truetype_get_font,
+ .get_font_size = console_truetype_get_font_size,
.select_font = truetype_select_font,
};
return ops->get_font(dev, seq, info);
}
+int vidconsole_get_font_size(struct udevice *dev, const char **name, uint *sizep)
+{
+ struct vidconsole_ops *ops = vidconsole_get_ops(dev);
+
+ if (!ops->get_font_size)
+ return -ENOSYS;
+
+ *name = ops->get_font_size(dev, sizep);
+ return 0;
+}
+
int vidconsole_select_font(struct udevice *dev, const char *name, uint size)
{
struct vidconsole_ops *ops = vidconsole_get_ops(dev);
int (*get_font)(struct udevice *dev, int seq,
struct vidfont_info *info);
+ /**
+ * get_font_size() - get the current font name and size
+ *
+ * @dev: vidconsole device
+ * @sizep: Place to put the font size (nominal height in pixels)
+ * Returns: Current font name
+ */
+ const char *(*get_font_size)(struct udevice *dev, uint *sizep);
+
/**
* select_font() - Select a particular font by name / size
*
*
* @dev: vidconsole device
* @sizep: Place to put the font size (nominal height in pixels)
- * Returns: Current font name
+ * @name: pointer to font name, a placeholder for result
+ * Return: 0 if OK, -ENOSYS if not implemented in driver
*/
-const char *vidconsole_get_font_size(struct udevice *dev, uint *sizep);
+int vidconsole_get_font_size(struct udevice *dev, const char **name, uint *sizep);
#ifdef CONFIG_VIDEO_COPY
/**
static int font_test_base(struct unit_test_state *uts)
{
struct udevice *dev;
+ const char *name;
int max_metrics;
uint size;
int ret;
ut_assert_nextline("cantoraone_regular");
ut_assertok(ut_check_console_end(uts));
- ut_asserteq_str("nimbus_sans_l_regular",
- vidconsole_get_font_size(dev, &size));
+ ut_assertok(vidconsole_get_font_size(dev, &name, &size));
+ ut_asserteq_str("nimbus_sans_l_regular", name);
ut_asserteq(18, size);
max_metrics = 1;
ut_assertok(ret);
ut_assertok(ut_check_console_end(uts));
- ut_asserteq_str("cantoraone_regular",
- vidconsole_get_font_size(dev, &size));
+ ut_assertok(vidconsole_get_font_size(dev, &name, &size));
+ ut_asserteq_str("cantoraone_regular", name);
ut_asserteq(40, size);
ut_assertok(run_command("font size 30", 0));
ut_assertok(ut_check_console_end(uts));
- ut_asserteq_str("cantoraone_regular",
- vidconsole_get_font_size(dev, &size));
+ ut_assertok(vidconsole_get_font_size(dev, &name, &size));
+ ut_asserteq_str("cantoraone_regular", name);
ut_asserteq(30, size);
return 0;