aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/radeon
diff options
context:
space:
mode:
authorChristian König <christian.koenig@amd.com>2014-01-23 11:50:49 -0500
committerChristian König <christian.koenig@amd.com>2014-02-18 10:11:26 -0500
commit98ccc291ffdc34ccb9b13f0c29cc51d6eab24022 (patch)
tree3033271c6e683095c118801dc3681f4ae8c4dfc2 /drivers/gpu/drm/radeon
parentf7ba8b04b22d7c74898f53a0e118f31b9d40dcc2 (diff)
drm/radeon: add VCE version parsing and checking
Also make the result available to userspace. Signed-off-by: Christian König <christian.koenig@amd.com>
Diffstat (limited to 'drivers/gpu/drm/radeon')
-rw-r--r--drivers/gpu/drm/radeon/radeon.h2
-rw-r--r--drivers/gpu/drm/radeon/radeon_kms.c6
-rw-r--r--drivers/gpu/drm/radeon/radeon_vce.c56
3 files changed, 58 insertions, 6 deletions
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index a58a38942c73..d1491d41fc2d 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -1606,6 +1606,8 @@ struct radeon_vce {
1606 struct radeon_bo *vcpu_bo; 1606 struct radeon_bo *vcpu_bo;
1607 void *cpu_addr; 1607 void *cpu_addr;
1608 uint64_t gpu_addr; 1608 uint64_t gpu_addr;
1609 unsigned fw_version;
1610 unsigned fb_version;
1609 atomic_t handles[RADEON_MAX_VCE_HANDLES]; 1611 atomic_t handles[RADEON_MAX_VCE_HANDLES];
1610 struct drm_file *filp[RADEON_MAX_VCE_HANDLES]; 1612 struct drm_file *filp[RADEON_MAX_VCE_HANDLES];
1611}; 1613};
diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c
index ea018d53a85e..baff98be65b1 100644
--- a/drivers/gpu/drm/radeon/radeon_kms.c
+++ b/drivers/gpu/drm/radeon/radeon_kms.c
@@ -480,6 +480,12 @@ static int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file
480 else 480 else
481 *value = rdev->pm.default_sclk * 10; 481 *value = rdev->pm.default_sclk * 10;
482 break; 482 break;
483 case RADEON_INFO_VCE_FW_VERSION:
484 *value = rdev->vce.fw_version;
485 break;
486 case RADEON_INFO_VCE_FB_VERSION:
487 *value = rdev->vce.fb_version;
488 break;
483 default: 489 default:
484 DRM_DEBUG_KMS("Invalid request %d\n", info->request); 490 DRM_DEBUG_KMS("Invalid request %d\n", info->request);
485 return -EINVAL; 491 return -EINVAL;
diff --git a/drivers/gpu/drm/radeon/radeon_vce.c b/drivers/gpu/drm/radeon/radeon_vce.c
index 2547d8ea347a..f46563b60921 100644
--- a/drivers/gpu/drm/radeon/radeon_vce.c
+++ b/drivers/gpu/drm/radeon/radeon_vce.c
@@ -48,8 +48,11 @@ MODULE_FIRMWARE(FIRMWARE_BONAIRE);
48 */ 48 */
49int radeon_vce_init(struct radeon_device *rdev) 49int radeon_vce_init(struct radeon_device *rdev)
50{ 50{
51 unsigned long bo_size; 51 static const char *fw_version = "[ATI LIB=VCEFW,";
52 const char *fw_name; 52 static const char *fb_version = "[ATI LIB=VCEFWSTATS,";
53 unsigned long size;
54 const char *fw_name, *c;
55 uint8_t start, mid, end;
53 int i, r; 56 int i, r;
54 57
55 switch (rdev->family) { 58 switch (rdev->family) {
@@ -70,9 +73,50 @@ int radeon_vce_init(struct radeon_device *rdev)
70 return r; 73 return r;
71 } 74 }
72 75
73 bo_size = RADEON_GPU_PAGE_ALIGN(rdev->vce_fw->size) + 76 /* search for firmware version */
74 RADEON_VCE_STACK_SIZE + RADEON_VCE_HEAP_SIZE; 77
75 r = radeon_bo_create(rdev, bo_size, PAGE_SIZE, true, 78 size = rdev->vce_fw->size - strlen(fw_version) - 9;
79 c = rdev->vce_fw->data;
80 for (;size > 0; --size, ++c)
81 if (strncmp(c, fw_version, strlen(fw_version)) == 0)
82 break;
83
84 if (size == 0)
85 return -EINVAL;
86
87 c += strlen(fw_version);
88 if (sscanf(c, "%2hhd.%2hhd.%2hhd]", &start, &mid, &end) != 3)
89 return -EINVAL;
90
91 /* search for feedback version */
92
93 size = rdev->vce_fw->size - strlen(fb_version) - 3;
94 c = rdev->vce_fw->data;
95 for (;size > 0; --size, ++c)
96 if (strncmp(c, fb_version, strlen(fb_version)) == 0)
97 break;
98
99 if (size == 0)
100 return -EINVAL;
101
102 c += strlen(fb_version);
103 if (sscanf(c, "%2u]", &rdev->vce.fb_version) != 1)
104 return -EINVAL;
105
106 DRM_INFO("Found VCE firmware/feedback version %hhd.%hhd.%hhd / %d!\n",
107 start, mid, end, rdev->vce.fb_version);
108
109 rdev->vce.fw_version = (start << 24) | (mid << 16) | (end << 8);
110
111 /* we can only work with this fw version for now */
112 if (rdev->vce.fw_version != ((40 << 24) | (2 << 16) | (2 << 8)))
113 return -EINVAL;
114
115 /* load firmware into VRAM */
116
117 size = RADEON_GPU_PAGE_ALIGN(rdev->vce_fw->size) +
118 RADEON_VCE_STACK_SIZE + RADEON_VCE_HEAP_SIZE;
119 r = radeon_bo_create(rdev, size, PAGE_SIZE, true,
76 RADEON_GEM_DOMAIN_VRAM, NULL, &rdev->vce.vcpu_bo); 120 RADEON_GEM_DOMAIN_VRAM, NULL, &rdev->vce.vcpu_bo);
77 if (r) { 121 if (r) {
78 dev_err(rdev->dev, "(%d) failed to allocate VCE bo\n", r); 122 dev_err(rdev->dev, "(%d) failed to allocate VCE bo\n", r);
@@ -83,7 +127,7 @@ int radeon_vce_init(struct radeon_device *rdev)
83 if (r) 127 if (r)
84 return r; 128 return r;
85 129
86 memset(rdev->vce.cpu_addr, 0, bo_size); 130 memset(rdev->vce.cpu_addr, 0, size);
87 memcpy(rdev->vce.cpu_addr, rdev->vce_fw->data, rdev->vce_fw->size); 131 memcpy(rdev->vce.cpu_addr, rdev->vce_fw->data, rdev->vce_fw->size);
88 132
89 r = radeon_vce_suspend(rdev); 133 r = radeon_vce_suspend(rdev);