drm/ast: Actually load DP501 firmware when required
authorEgbert Eich <eich@suse.de>
Tue, 18 Jul 2017 14:47:40 +0000 (16:47 +0200)
committerDave Airlie <airlied@redhat.com>
Wed, 2 Aug 2017 02:13:16 +0000 (12:13 +1000)
The ast driver has a code to load the DP501 firmware, but it's never
used.  This patch implements its actual usage by requesting the
firmware on demand, and release the firmware at exit as well.

Also the path contains a few cleanups and makes relevant functions
static.

Signed-off-by: Egbert Eich <eich@suse.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/ast/ast_dp501.c
drivers/gpu/drm/ast/ast_drv.h
drivers/gpu/drm/ast/ast_main.c

index 76f07f38b941f5e8ea3ad9255e8870b293bfab84..749646ae365fc36e7ab64df83228a9f04a472fc7 100644 (file)
@@ -4,16 +4,11 @@
 #include "ast_drv.h"
 MODULE_FIRMWARE("ast_dp501_fw.bin");
 
-int ast_load_dp501_microcode(struct drm_device *dev)
+static int ast_load_dp501_microcode(struct drm_device *dev)
 {
        struct ast_private *ast = dev->dev_private;
-       static char *fw_name = "ast_dp501_fw.bin";
-       int err;
-       err = request_firmware(&ast->dp501_fw, fw_name, dev->dev);
-       if (err)
-               return err;
 
-       return 0;
+       return request_firmware(&ast->dp501_fw, "ast_dp501_fw.bin", dev->dev);
 }
 
 static void send_ack(struct ast_private *ast)
@@ -187,7 +182,7 @@ bool ast_backup_fw(struct drm_device *dev, u8 *addr, u32 size)
        return false;
 }
 
-bool ast_launch_m68k(struct drm_device *dev)
+static bool ast_launch_m68k(struct drm_device *dev)
 {
        struct ast_private *ast = dev->dev_private;
        u32 i, data, len = 0;
@@ -201,7 +196,11 @@ bool ast_launch_m68k(struct drm_device *dev)
                if (ast->dp501_fw_addr) {
                        fw_addr = ast->dp501_fw_addr;
                        len = 32*1024;
-               } else if (ast->dp501_fw) {
+               } else {
+                       if (!ast->dp501_fw &&
+                           ast_load_dp501_microcode(dev) < 0)
+                               return false;
+
                        fw_addr = (u8 *)ast->dp501_fw->data;
                        len = ast->dp501_fw->size;
                }
@@ -432,3 +431,11 @@ void ast_init_3rdtx(struct drm_device *dev)
                }
        }
 }
+
+void ast_release_firmware(struct drm_device *dev)
+{
+       struct ast_private *ast = dev->dev_private;
+
+       release_firmware(ast->dp501_fw);
+       ast->dp501_fw = NULL;
+}
index 8880f0b62e9c2832845d7df2f40e0e77817a9f91..7ded3b84237f82b9b35cfdab0117ecbb45ef3de2 100644 (file)
@@ -401,11 +401,10 @@ void ast_post_gpu(struct drm_device *dev);
 u32 ast_mindwm(struct ast_private *ast, u32 r);
 void ast_moutdwm(struct ast_private *ast, u32 r, u32 v);
 /* ast dp501 */
-int ast_load_dp501_microcode(struct drm_device *dev);
 void ast_set_dp501_video_output(struct drm_device *dev, u8 mode);
-bool ast_launch_m68k(struct drm_device *dev);
 bool ast_backup_fw(struct drm_device *dev, u8 *addr, u32 size);
 bool ast_dp501_read_edid(struct drm_device *dev, u8 *ediddata);
 u8 ast_get_dp501_max_clk(struct drm_device *dev);
 void ast_init_3rdtx(struct drm_device *dev);
+void ast_release_firmware(struct drm_device *dev);
 #endif
index 50a8512ea646376513672532bb504dd0d77ff749..9a44cdec3bca210b6d6561d64a17489d21dc6755 100644 (file)
@@ -576,6 +576,7 @@ void ast_driver_unload(struct drm_device *dev)
 {
        struct ast_private *ast = dev->dev_private;
 
+       ast_release_firmware(dev);
        kfree(ast->dp501_fw_addr);
        ast_mode_fini(dev);
        ast_fbdev_fini(dev);