thor: Add API for thor status notifications
authorSylwester Nawrocki <s.nawrocki@samsung.com>
Wed, 25 Nov 2020 17:54:28 +0000 (18:54 +0100)
committerMarek Szyprowski <m.szyprowski@samsung.com>
Fri, 12 Nov 2021 14:33:59 +0000 (15:33 +0100)
This patch adds an empty by default thor_status_notify() function which
can be reimplemented as required and which allows to add notifications
of thor status and flashing progress, e.g. on external monitor.

Change-Id: Ic1eaad7f3f5adbca404162b745a9287d5a9ae247
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
cmd/thordown.c
drivers/usb/gadget/f_thor.c
include/thor.h

index 9c96cf45b6ab1e8d426a5e234b3c191a884fb07a..579dc315908ca6a83a2deac5d8dad0a4f9f651f3 100644 (file)
@@ -105,6 +105,8 @@ done:
        } else
                lcd_clear();
 #endif
+       if (ret != CMD_RET_SUCCESS)
+               thor_status_notify(THOR_NOTIFY_DOWNLOAD_FAILED, NULL);
 #endif
 bad_args:
        if (argc == 1) {
@@ -115,6 +117,11 @@ bad_args:
        return ret;
 }
 
+__weak void thor_status_notify(enum thor_notify_type type,
+                       struct thor_notify_data *data)
+{
+}
+
 U_BOOT_CMD(thordown, CONFIG_SYS_MAXARGS, 1, do_thor_down,
           "TIZEN \"THOR\" downloader",
           "<USB_controller> <interface> <dev>\n"
index 72be423e2dbcc8883c31f8293dd38a0cb8bca555..b22f86f650afb06e26b30ba0209d62a47a8eb682 100644 (file)
@@ -551,6 +551,9 @@ static struct usb_request *alloc_ep_req(struct usb_ep *ep, unsigned length)
 static int thor_rx_data(size_t *received)
 {
        struct thor_dev *dev = thor_func->dev;
+#ifdef CONFIG_TIZEN
+       struct thor_notify_data nd;
+#endif
        size_t data_to_rx;
        int status;
 
@@ -579,6 +582,11 @@ static int thor_rx_data(size_t *received)
                data_to_rx -= dev->out_req->actual;
 #ifdef CONFIG_TIZEN
                downloaded_file_size += dev->out_req->actual;
+
+               nd.total_size = total_file_size;
+               nd.current_size = downloaded_file_size;
+               thor_status_notify(THOR_NOTIFY_PROGRESS, &nd);
+
 #ifdef CONFIG_LCD      /* TODO : Need to enable LCD*/
 #ifdef CONFIG_OF_MULTI
                if (board_is_trats2())
@@ -718,6 +726,8 @@ int thor_init(void)
        size_t received;
        int ret;
 
+       thor_status_notify(THOR_NOTIFY_INIT, NULL);
+
 #ifdef CONFIG_TIZEN
 #ifdef CONFIG_LCD      /* TODO : Need to enable LCD*/
        draw_thor_init_screen();
@@ -753,6 +763,8 @@ int thor_init(void)
        draw_thor_connected();
 #endif
 #endif
+       thor_status_notify(THOR_NOTIFY_CONNECTED, NULL);
+
 #endif /* CONFIG_TIZEN */
        thor_set_dma(thor_rx_data_buf, strlen("THOR"));
        /* detect the download request from Host PC */
index ee67ab0a2704ed6080d10f4348c44401633716d7..171b8b8827b49002848b37a383e78e8fabc5915a 100644 (file)
 int thor_handle(void);
 int thor_init(void);
 int thor_add(struct usb_configuration *c);
+
+enum thor_notify_type {
+       THOR_NOTIFY_INIT,
+       THOR_NOTIFY_CONNECTED,
+       THOR_NOTIFY_PROGRESS,
+       THOR_NOTIFY_DOWNLOAD_FAILED,
+};
+
+struct thor_notify_data {
+       u64 total_size;
+       u64 current_size;
+};
+
+void thor_status_notify(enum thor_notify_type type,
+                       struct thor_notify_data *data);
 #endif /* __THOR_H_ */