Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src move all the radeondrm firmware images into the filesystem. ...
details: https://anonhg.NetBSD.org/src/rev/a3842615fa4f
branches: trunk
changeset: 756061:a3842615fa4f
user: mrg <mrg%NetBSD.org@localhost>
date: Mon Jul 05 20:32:23 2010 +0000
description:
move all the radeondrm firmware images into the filesystem. check that
some firmware sizes are the expected size. (XXX make all.)
based upon similar changes seen in the linux radeon drm driver.
this saves about 250KB in the kernel or module.
diffstat:
distrib/sets/lists/base/mi | 44 ++++++-
sys/dev/microcode/Makefile | 3 +-
sys/external/bsd/drm/dist/bsd-core/radeon_drv.c | 34 +++++
sys/external/bsd/drm/dist/shared-core/r600_cp.c | 133 +++++++++++---------
sys/external/bsd/drm/dist/shared-core/radeon_cp.c | 37 +++--
sys/external/bsd/drm/dist/shared-core/radeon_drv.h | 4 +
6 files changed, 176 insertions(+), 79 deletions(-)
diffs (truncated from 465 to 300 lines):
diff -r adec106768b6 -r a3842615fa4f distrib/sets/lists/base/mi
--- a/distrib/sets/lists/base/mi Mon Jul 05 17:12:48 2010 +0000
+++ b/distrib/sets/lists/base/mi Mon Jul 05 20:32:23 2010 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.873 2010/07/03 08:16:50 jmmv Exp $
+# $NetBSD: mi,v 1.874 2010/07/05 20:32:23 mrg Exp $
#
# Note: Don't delete entries from here - mark them as "obsolete" instead,
# unless otherwise stated below.
@@ -881,6 +881,48 @@
./usr/libdata/debug/usr/mdec base-sys-usr
./usr/libdata/debug/usr/sbin base-sys-usr
./usr/libdata/firmware base-sys-usr
+./usr/libdata/firmware/radeon base-sys-usr
+./usr/libdata/firmware/radeon/CEDAR_me.bin base-sys-usr
+./usr/libdata/firmware/radeon/CEDAR_pfp.bin base-sys-usr
+./usr/libdata/firmware/radeon/CEDAR_rlc.bin base-sys-usr
+./usr/libdata/firmware/radeon/CYPRESS_me.bin base-sys-usr
+./usr/libdata/firmware/radeon/CYPRESS_pfp.bin base-sys-usr
+./usr/libdata/firmware/radeon/CYPRESS_rlc.bin base-sys-usr
+./usr/libdata/firmware/radeon/JUNIPER_me.bin base-sys-usr
+./usr/libdata/firmware/radeon/JUNIPER_pfp.bin base-sys-usr
+./usr/libdata/firmware/radeon/JUNIPER_rlc.bin base-sys-usr
+./usr/libdata/firmware/radeon/R100_cp.bin base-sys-usr
+./usr/libdata/firmware/radeon/R200_cp.bin base-sys-usr
+./usr/libdata/firmware/radeon/R300_cp.bin base-sys-usr
+./usr/libdata/firmware/radeon/R420_cp.bin base-sys-usr
+./usr/libdata/firmware/radeon/R520_cp.bin base-sys-usr
+./usr/libdata/firmware/radeon/R600_me.bin base-sys-usr
+./usr/libdata/firmware/radeon/R600_pfp.bin base-sys-usr
+./usr/libdata/firmware/radeon/R600_rlc.bin base-sys-usr
+./usr/libdata/firmware/radeon/R700_rlc.bin base-sys-usr
+./usr/libdata/firmware/radeon/REDWOOD_me.bin base-sys-usr
+./usr/libdata/firmware/radeon/REDWOOD_pfp.bin base-sys-usr
+./usr/libdata/firmware/radeon/REDWOOD_rlc.bin base-sys-usr
+./usr/libdata/firmware/radeon/RS600_cp.bin base-sys-usr
+./usr/libdata/firmware/radeon/RS690_cp.bin base-sys-usr
+./usr/libdata/firmware/radeon/RS780_me.bin base-sys-usr
+./usr/libdata/firmware/radeon/RS780_pfp.bin base-sys-usr
+./usr/libdata/firmware/radeon/RV610_me.bin base-sys-usr
+./usr/libdata/firmware/radeon/RV610_pfp.bin base-sys-usr
+./usr/libdata/firmware/radeon/RV620_me.bin base-sys-usr
+./usr/libdata/firmware/radeon/RV620_pfp.bin base-sys-usr
+./usr/libdata/firmware/radeon/RV630_me.bin base-sys-usr
+./usr/libdata/firmware/radeon/RV630_pfp.bin base-sys-usr
+./usr/libdata/firmware/radeon/RV635_me.bin base-sys-usr
+./usr/libdata/firmware/radeon/RV635_pfp.bin base-sys-usr
+./usr/libdata/firmware/radeon/RV670_me.bin base-sys-usr
+./usr/libdata/firmware/radeon/RV670_pfp.bin base-sys-usr
+./usr/libdata/firmware/radeon/RV710_me.bin base-sys-usr
+./usr/libdata/firmware/radeon/RV710_pfp.bin base-sys-usr
+./usr/libdata/firmware/radeon/RV730_me.bin base-sys-usr
+./usr/libdata/firmware/radeon/RV730_pfp.bin base-sys-usr
+./usr/libdata/firmware/radeon/RV770_me.bin base-sys-usr
+./usr/libdata/firmware/radeon/RV770_pfp.bin base-sys-usr
./usr/libdata/ldscripts base-c-usr
./usr/libdata/lint base-c-usr
./usr/libexec base-sys-usr
diff -r adec106768b6 -r a3842615fa4f sys/dev/microcode/Makefile
--- a/sys/dev/microcode/Makefile Mon Jul 05 17:12:48 2010 +0000
+++ b/sys/dev/microcode/Makefile Mon Jul 05 20:32:23 2010 +0000
@@ -1,5 +1,6 @@
-# $NetBSD: Makefile,v 1.7 2007/06/09 11:20:56 kiyohara Exp $
+# $NetBSD: Makefile,v 1.8 2010/07/05 20:32:24 mrg Exp $
SUBDIR+= ral rum zyd
+SUBDIR+= radeon
.include <bsd.subdir.mk>
diff -r adec106768b6 -r a3842615fa4f sys/external/bsd/drm/dist/bsd-core/radeon_drv.c
--- a/sys/external/bsd/drm/dist/bsd-core/radeon_drv.c Mon Jul 05 17:12:48 2010 +0000
+++ b/sys/external/bsd/drm/dist/bsd-core/radeon_drv.c Mon Jul 05 20:32:23 2010 +0000
@@ -259,4 +259,38 @@
}
#endif /* _MODULE */
+
+#include <dev/firmload.h>
+
+int radeon_load_a_microcode(const char *fmt, const char *chip_name, void **codep, size_t *sizep)
+{
+ firmware_handle_t fh;
+ char fw_name[30];
+ int error;
+
+ snprintf(fw_name, sizeof(fw_name), fmt, chip_name);
+ if ((error = firmware_open("radeon", fw_name, &fh)) != 0) {
+ DRM_ERROR("Cannot open radeon/%s firmware: %d\n", fw_name, error);
+ return error;
+ }
+ *sizep = firmware_get_size(fh);
+ if ((*codep = firmware_malloc(*sizep)) == NULL) {
+ DRM_ERROR("Cannot alloc memory for radeon/%s firmware\n", chip_name);
+ firmware_close(fh);
+ return ENOMEM;
+ }
+ if ((error = firmware_read(fh, 0, *codep, *sizep)) != 0) {
+ DRM_ERROR("Cannot read radeon/%s firmware: %d\n", chip_name, error);
+ firmware_free(*codep, *sizep);
+ }
+ firmware_close(fh);
+
+ return error;
+}
+
+void radeon_free_a_microcode(void *code, size_t size)
+{
+ firmware_free(code, size);
+}
+
#endif
diff -r adec106768b6 -r a3842615fa4f sys/external/bsd/drm/dist/shared-core/r600_cp.c
--- a/sys/external/bsd/drm/dist/shared-core/r600_cp.c Mon Jul 05 17:12:48 2010 +0000
+++ b/sys/external/bsd/drm/dist/shared-core/r600_cp.c Mon Jul 05 20:32:23 2010 +0000
@@ -33,8 +33,12 @@
#include "radeon_drv.h"
#include "r300_reg.h"
-#include "r600_microcode.h"
-#include "radeonhd_microcode.h"
+#define PFP_UCODE_SIZE 576
+#define PM4_UCODE_SIZE 1792
+#define R700_PFP_UCODE_SIZE 848
+#define R700_PM4_UCODE_SIZE 1360
+#define EVERGREEN_PFP_UCODE_SIZE 1120
+#define EVERGREEN_PM4_UCODE_SIZE 1376
# define ATI_PCIGART_PAGE_SIZE 4096 /**< PCI GART page size */
# define ATI_PCIGART_PAGE_MASK (~(ATI_PCIGART_PAGE_SIZE-1))
@@ -285,51 +289,48 @@
/* load r600 microcode */
static void r600_cp_load_microcode(drm_radeon_private_t * dev_priv)
{
- const u32 (*cp)[3];
- const u32 *pfp;
- int i;
+ const char *chip_name;
+ u32 (*me)[3];
+ u32 *pfp;
+ size_t pfp_size, me_size;
+ int i, error;
switch (dev_priv->flags & RADEON_FAMILY_MASK) {
case CHIP_R600:
- DRM_INFO("Loading R600 Microcode\n");
- cp = R600_cp_microcode;
- pfp = R600_pfp_microcode;
+ chip_name = "R600";
break;
case CHIP_RV610:
- DRM_INFO("Loading RV610 Microcode\n");
- cp = RV610_cp_microcode;
- pfp = RV610_pfp_microcode;
+ chip_name = "RV610";
break;
case CHIP_RV630:
- DRM_INFO("Loading RV630 Microcode\n");
- cp = RV630_cp_microcode;
- pfp = RV630_pfp_microcode;
+ chip_name = "RV630";
break;
case CHIP_RV620:
- DRM_INFO("Loading RV620 Microcode\n");
- cp = RV620_cp_microcode;
- pfp = RV620_pfp_microcode;
+ chip_name = "RV620";
break;
case CHIP_RV635:
- DRM_INFO("Loading RV635 Microcode\n");
- cp = RV635_cp_microcode;
- pfp = RV635_pfp_microcode;
+ chip_name = "RV635";
break;
case CHIP_RV670:
- DRM_INFO("Loading RV670 Microcode\n");
- cp = RV670_cp_microcode;
- pfp = RV670_pfp_microcode;
+ chip_name = "RV670";
break;
case CHIP_RS780:
case CHIP_RS880:
- DRM_INFO("Loading RS780/RS880 Microcode\n");
- cp = RS780_cp_microcode;
- pfp = RS780_pfp_microcode;
+ chip_name = "RS780";
break;
default:
return;
}
+ DRM_INFO("Loading %s Microcode\n", chip_name);
+
+ if ((error = radeon_load_a_microcode("%s_pfp.bin", chip_name, (void **)&pfp, &pfp_size)) != 0)
+ return;
+ if ((error = radeon_load_a_microcode("%s_me.bin", chip_name, (void **)&me, &me_size)) != 0) {
+ radeon_free_a_microcode(pfp, pfp_size);
+ return;
+ }
+
r600_do_cp_stop(dev_priv);
RADEON_WRITE(R600_CP_RB_CNTL,
@@ -345,19 +346,21 @@
RADEON_WRITE(R600_CP_ME_RAM_WADDR, 0);
for (i = 0; i < PM4_UCODE_SIZE; i++) {
- RADEON_WRITE(R600_CP_ME_RAM_DATA, cp[i][0]);
- RADEON_WRITE(R600_CP_ME_RAM_DATA, cp[i][1]);
- RADEON_WRITE(R600_CP_ME_RAM_DATA, cp[i][2]);
+ RADEON_WRITE(R600_CP_ME_RAM_DATA, be32toh(me[i][0]));
+ RADEON_WRITE(R600_CP_ME_RAM_DATA, be32toh(me[i][1]));
+ RADEON_WRITE(R600_CP_ME_RAM_DATA, be32toh(me[i][2]));
}
RADEON_WRITE(R600_CP_PFP_UCODE_ADDR, 0);
for (i = 0; i < PFP_UCODE_SIZE; i++)
- RADEON_WRITE(R600_CP_PFP_UCODE_DATA, pfp[i]);
+ RADEON_WRITE(R600_CP_PFP_UCODE_DATA, be32toh(pfp[i]));
RADEON_WRITE(R600_CP_PFP_UCODE_ADDR, 0);
RADEON_WRITE(R600_CP_ME_RAM_WADDR, 0);
RADEON_WRITE(R600_CP_ME_RAM_RADDR, 0);
+ radeon_free_a_microcode(pfp, pfp_size);
+ radeon_free_a_microcode(me, me_size);
}
static void r700_vm_init(struct drm_device *dev)
@@ -417,53 +420,49 @@
static void r700_cp_load_microcode(drm_radeon_private_t * dev_priv)
{
size_t pfp_req_size, me_req_size;
-
- const u32 *pfp;
- const u32 *cp;
- int i;
+ const char *chip_name;
+ u32 *pfp;
+ u32 *me;
+ size_t pfp_size, me_size;
+ int i, error;
switch (dev_priv->flags & RADEON_FAMILY_MASK) {
case CHIP_RV770:
- DRM_INFO("Loading RV770/RV790 Microcode\n");
- pfp = RV770_pfp_microcode;
- cp = RV770_cp_microcode;
+ chip_name = "RV770";
break;
case CHIP_RV730:
case CHIP_RV740:
- DRM_INFO("Loading RV730/RV740 Microcode\n");
- pfp = RV730_pfp_microcode;
- cp = RV730_cp_microcode;
+ chip_name = "RV730";
break;
case CHIP_RV710:
- DRM_INFO("Loading RV710 Microcode\n");
- pfp = RV710_pfp_microcode;
- cp = RV710_cp_microcode;
+ chip_name = "RV710";
break;
case CHIP_CEDAR:
- DRM_INFO("Loading CEDAR Microcode\n");
- pfp = CEDAR_pfp_microcode;
- cp = CEDAR_me_microcode;
+ chip_name = "CEDAR";
break;
case CHIP_REDWOOD:
- DRM_INFO("Loading REDWOOD Microcode\n");
- pfp = REDWOOD_pfp_microcode;
- cp = REDWOOD_me_microcode;
+ chip_name = "REDWOOD";
break;
case CHIP_JUNIPER:
- DRM_INFO("Loading JUNIPER Microcode\n");
- pfp = JUNIPER_pfp_microcode;
- cp = JUNIPER_me_microcode;
+ chip_name = "JUNIPER";
break;
case CHIP_CYPRESS:
case CHIP_HEMLOCK:
- DRM_INFO("Loading CYPRESS Microcode\n");
- pfp = CYPRESS_pfp_microcode;
- cp = CYPRESS_me_microcode;
+ chip_name = "CYPRESS";
break;
default:
return;
}
+ DRM_INFO("Loading %s Microcode\n", chip_name);
+
+ if ((error = radeon_load_a_microcode("%s_pfp.bin", chip_name, (void **)&pfp, &pfp_size)) != 0)
+ return;
+ if ((error = radeon_load_a_microcode("%s_me.bin", chip_name, (void **)&me, &me_size)) != 0) {
+ radeon_free_a_microcode(pfp, pfp_size);
+ return;
+ }
+
Home |
Main Index |
Thread Index |
Old Index