thor: Add API for thor status notifications
authorSylwester Nawrocki <s.nawrocki@samsung.com>
Wed, 25 Nov 2020 17:54:28 +0000 (18:54 +0100)
committerJaehoon Chung <jh80.chung@samsung.com>
Mon, 28 Oct 2024 11:28:33 +0000 (20:28 +0900)
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 d1e1300957c6e32177d7ee8669b54c61f6e355dd..17c0bb63cba3e42cbd8097a39d3d3dcff1dfb2f6 100644 (file)
@@ -103,6 +103,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) {
@@ -113,6 +115,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 5b4b8b310660bc69194c6e2ad6f309579e63ceff..ba7c90521d1c13b80aa316421f1c8b988597b5bf 100644 (file)
@@ -554,6 +554,9 @@ static int thor_rx_data(struct udevice *udc)
 {
        struct thor_dev *dev = thor_func->dev;
        size_t data_to_rx, tmp;
+#ifdef CONFIG_TIZEN
+       struct thor_notify_data nd;
+#endif
        int status;
 
        data_to_rx = dev->out_req->length;
@@ -581,6 +584,11 @@ static int thor_rx_data(struct udevice *udc)
                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*/
                draw_thor_progress(total_file_size, downloaded_file_size);
 #endif
@@ -713,6 +721,8 @@ int thor_init(struct udevice *udc)
        int power_key_cnt = 0;
        int ret;
 
+       thor_status_notify(THOR_NOTIFY_INIT, NULL);
+
 #ifdef CONFIG_TIZEN
 #ifdef CONFIG_LCD      /* TODO : Need to enable LCD*/
        draw_thor_init_screen();
@@ -741,6 +751,8 @@ int thor_init(struct udevice *udc)
        draw_thor_connected();
 #endif
 #endif
+       thor_status_notify(THOR_NOTIFY_CONNECTED, NULL);
+
        thor_set_dma(thor_rx_data_buf, strlen("THOR"));
        /* detect the download request from Host PC */
        ret = thor_rx_data(udc);
index 3cb56b654ae00a0ebfe8aee91c6b1480d1394fdb..1383f34ce8bc4be8ddbbbefb68c3f3e8314953c6 100644 (file)
 int thor_handle(struct udevice *udc);
 int thor_init(struct udevice *udc);
 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_ */