[PATCH] baum: send device identity and cell count on protocol off/on

Samuel Thibault posted 1 patch 1 day, 21 hours ago
There is a newer version of this series
chardev/baum.c | 32 ++++++++++++++++++++++++--------
1 file changed, 24 insertions(+), 8 deletions(-)
[PATCH] baum: send device identity and cell count on protocol off/on
Posted by Samuel Thibault 1 day, 21 hours ago
The hardware devices do identify themselves when the driver turns the
protocol off and on again. NVDA expects to get it.
---
 chardev/baum.c | 32 ++++++++++++++++++++++++--------
 1 file changed, 24 insertions(+), 8 deletions(-)

diff --git a/chardev/baum.c b/chardev/baum.c
index 166d6f2f09..db0a4fff75 100644
--- a/chardev/baum.c
+++ b/chardev/baum.c
@@ -97,6 +97,7 @@ struct BaumChardev {
     brlapi_fileDescriptor brlapi_fd;
     unsigned int x, y;
     bool deferred_init;
+    bool protocol_on;
 
     uint8_t in_buf[BUF_SIZE];
     uint8_t in_buf_used;
@@ -337,13 +338,27 @@ static void baum_write_packet(BaumChardev *baum, const uint8_t *buf, int len)
     }
 }
 
+static void baum_send_cell_count(BaumChardev *baum)
+{
+    uint8_t cell_count[] = { BAUM_RSP_CellCount, baum->x * baum->y };
+    baum_write_packet(baum, cell_count, sizeof(cell_count));
+}
+
+static void baum_send_device_identity(BaumChardev *baum)
+{
+    uint8_t identity[17] = { BAUM_RSP_DeviceIdentity,
+        'B','a','u','m',' ','V','a','r','i','o' };
+    identity[11] = '0' + baum->x / 10;
+    identity[12] = '0' + baum->x % 10;
+    baum_write_packet(baum, identity, sizeof(identity));
+}
+
 /* Called when the other end seems to have a wrong idea of our display size */
 static void baum_cellCount_timer_cb(void *opaque)
 {
     BaumChardev *baum = BAUM_CHARDEV(opaque);
-    uint8_t cell_count[] = { BAUM_RSP_CellCount, baum->x * baum->y };
     DPRINTF("Timeout waiting for DisplayData, sending cell count\n");
-    baum_write_packet(baum, cell_count, sizeof(cell_count));
+    baum_send_cell_count(baum);
 }
 
 /* Try to interpret a whole incoming packet */
@@ -441,17 +456,18 @@ static int baum_eat_packet(BaumChardev *baum, const uint8_t *buf, int len)
         uint8_t protocol;
         DPRINTF("SetProtocol\n");
         EAT(protocol);
-        /* ignore */
+        if (!baum->protocol_on && protocol) {
+            /* Switching on, answer with device identity and cell count */
+            baum_send_device_identity(baum);
+            baum_send_cell_count(baum);
+        }
+        baum->protocol_on = protocol;
         break;
     }
     case BAUM_REQ_GetDeviceIdentity:
     {
-        uint8_t identity[17] = { BAUM_RSP_DeviceIdentity,
-            'B','a','u','m',' ','V','a','r','i','o' };
         DPRINTF("GetDeviceIdentity\n");
-        identity[11] = '0' + baum->x / 10;
-        identity[12] = '0' + baum->x % 10;
-        baum_write_packet(baum, identity, sizeof(identity));
+        baum_send_device_identity(baum);
         break;
     }
     case BAUM_REQ_GetVersionNumber:
-- 
2.53.0
Re: [PATCH] baum: send device identity and cell count on protocol off/on
Posted by marcandre.lureau@redhat.com 1 day, 8 hours ago
> The hardware devices do identify themselves when the driver turns the
> protocol off and on again. NVDA expects to get it.
> Message-ID: <20261021230736.1451533-1-samuel.thibault@ens-lyon.org>

Missing required Signed-off-by

> ---
>  chardev/baum.c | 32 ++++++++++++++++++++++++--------
>  1 file changed, 24 insertions(+), 8 deletions(-)
>
> diff --git a/chardev/baum.c b/chardev/baum.c
> index ac1e535ba8e9..e60fb628e0ff 100644
> --- a/chardev/baum.c
> +++ b/chardev/baum.c
> @@ -97,6 +97,7 @@ struct BaumChardev {
>      brlapi_fileDescriptor brlapi_fd;
>      unsigned int x, y;
>      bool deferred_init;
> +    bool protocol_on;

reset it alongside deferred_init? or document if it's intentional

>  
>      uint8_t in_buf[BUF_SIZE];
>      uint8_t in_buf_used;
> @@ -337,13 +338,27 @@ static void baum_write_packet(BaumChardev *baum, const uint8_t *buf, int len)
>      }
>  }
>  
> +static void baum_send_cell_count(BaumChardev *baum)
> +{
> +    uint8_t cell_count[] = { BAUM_RSP_CellCount, baum->x * baum->y };
> +    baum_write_packet(baum, cell_count, sizeof(cell_count));
> +}
> +
> +static void baum_send_device_identity(BaumChardev *baum)
> +{
> +    uint8_t identity[17] = { BAUM_RSP_DeviceIdentity,
> +        'B','a','u','m',' ','V','a','r','i','o' };
> +    identity[11] = '0' + baum->x / 10;
> +    identity[12] = '0' + baum->x % 10;
> +    baum_write_packet(baum, identity, sizeof(identity));
> +}
> +
>  /* Called when the other end seems to have a wrong idea of our display size */
>  static void baum_cellCount_timer_cb(void *opaque)
>  {
>      BaumChardev *baum = BAUM_CHARDEV(opaque);
> -    uint8_t cell_count[] = { BAUM_RSP_CellCount, baum->x * baum->y };
>      DPRINTF("Timeout waiting for DisplayData, sending cell count\n");
> -    baum_write_packet(baum, cell_count, sizeof(cell_count));
> +    baum_send_cell_count(baum);
>  }
>  
>  /* Try to interpret a whole incoming packet */
> @@ -441,17 +456,18 @@ static int baum_eat_packet(BaumChardev *baum, const uint8_t *buf, int len)
>          uint8_t protocol;
>          DPRINTF("SetProtocol\n");
>          EAT(protocol);
> -        /* ignore */
> +        if (!baum->protocol_on && protocol) {

Maybe it should respond on all ->on "if (protocol)"?

-- 
Marc-André Lureau <marcandre.lureau@redhat.com>


Re: [PATCH] baum: send device identity and cell count on protocol off/on
Posted by Samuel Thibault 22 hours ago
Hello,

marcandre.lureau@redhat.com, le jeu. 22 oct. 2026 16:09:45 +0400, a ecrit:
> > The hardware devices do identify themselves when the driver turns the
> > protocol off and on again. NVDA expects to get it.
> > Message-ID: <20261021230736.1451533-1-samuel.thibault@ens-lyon.org>
> 
> Missing required Signed-off-by

Oops, right.

> > ---
> >  chardev/baum.c | 32 ++++++++++++++++++++++++--------
> >  1 file changed, 24 insertions(+), 8 deletions(-)
> >
> > diff --git a/chardev/baum.c b/chardev/baum.c
> > index ac1e535ba8e9..e60fb628e0ff 100644
> > --- a/chardev/baum.c
> > +++ b/chardev/baum.c
> > @@ -97,6 +97,7 @@ struct BaumChardev {
> >      brlapi_fileDescriptor brlapi_fd;
> >      unsigned int x, y;
> >      bool deferred_init;
> > +    bool protocol_on;
> 
> reset it alongside deferred_init? or document if it's intentional

It's only x,y that are not know before deferred_init. I have separated
them out.

> > @@ -441,17 +456,18 @@ static int baum_eat_packet(BaumChardev *baum, const uint8_t *buf, int len)
> >          uint8_t protocol;
> >          DPRINTF("SetProtocol\n");
> >          EAT(protocol);
> > -        /* ignore */
> > +        if (!baum->protocol_on && protocol) {
> 
> Maybe it should respond on all ->on "if (protocol)"?

I was told that “A real display answers only when the protocol goes
from off to on”.

Thanks!
Samuel