Skip to content

Commit

Permalink
drm/ast: Actually load DP501 firmware when required
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Egbert Eich authored and Dave Airlie committed Aug 2, 2017
1 parent ab209c3 commit 12f8030
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
25 changes: 16 additions & 9 deletions drivers/gpu/drm/ast/ast_dp501.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
}
3 changes: 1 addition & 2 deletions drivers/gpu/drm/ast/ast_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions drivers/gpu/drm/ast/ast_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 12f8030

Please sign in to comment.