diff mbox

[U-Boot,08/19] video: Provide a backspace method

Message ID 1452820252-2126-9-git-send-email-sjg@chromium.org
State Accepted
Commit 7b9f7e445e13de4f3169d9e5ba5e3b28c4d79ce4
Delegated to: Anatolij Gustschin
Headers show

Commit Message

Simon Glass Jan. 15, 2016, 1:10 a.m. UTC
With proportional fonts the vidconsole uclass cannot itself erase the
previous character. Provide an optional method so that the driver can
handle this operation.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/video/vidconsole-uclass.c | 12 +++++++++++-
 include/video_console.h           | 14 ++++++++++++++
 2 files changed, 25 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c
index 182aaed..832e90a 100644
--- a/drivers/video/vidconsole-uclass.c
+++ b/drivers/video/vidconsole-uclass.c
@@ -57,9 +57,17 @@  static int vidconsole_entry_start(struct udevice *dev)
 }
 
 /* Move backwards one space */
-static void vidconsole_back(struct udevice *dev)
+static int vidconsole_back(struct udevice *dev)
 {
 	struct vidconsole_priv *priv = dev_get_uclass_priv(dev);
+	struct vidconsole_ops *ops = vidconsole_get_ops(dev);
+	int ret;
+
+	if (ops->backspace) {
+		ret = ops->backspace(dev);
+		if (ret != -ENOSYS)
+			return ret;
+	}
 
 	priv->xcur_frac -= VID_TO_POS(priv->x_charsize);
 	if (priv->xcur_frac < priv->xstart_frac) {
@@ -69,6 +77,8 @@  static void vidconsole_back(struct udevice *dev)
 		if (priv->ycur < 0)
 			priv->ycur = 0;
 	}
+
+	return 0;
 }
 
 /* Move to a newline, scrolling the display if necessary */
diff --git a/include/video_console.h b/include/video_console.h
index 80bc948..1345748 100644
--- a/include/video_console.h
+++ b/include/video_console.h
@@ -101,6 +101,20 @@  struct vidconsole_ops {
 	 * positions.
 	 */
 	int (*entry_start)(struct udevice *dev);
+
+	/**
+	 * backspace() - Handle erasing the last character
+	 *
+	 * With proportional fonts the vidconsole uclass cannot itself erase
+	 * the previous character. This optional method will be called when
+	 * a backspace is needed. The driver should erase the previous
+	 * character and update the cursor position (xcur_frac, ycur) to the
+	 * start of the previous character.
+	 *
+	 * If not implement, default behaviour will work for fixed-width
+	 * characters.
+	 */
+	int (*backspace)(struct udevice *dev);
 };
 
 /* Get a pointer to the driver operations for a video console device */