]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
drm/amdgpu/uvd: consolidate code for fetching addr from ctx
authorAlex Deucher <alexander.deucher@amd.com>
Mon, 21 Nov 2016 21:24:37 +0000 (16:24 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 23 Nov 2016 20:08:47 +0000 (15:08 -0500)
Same code duplicated in both functions.

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c

index fb270c7e7171d614c21fd9e4678a7ff2fe58f6b2..330c4749b32cb402b4a9fdbfb762f06186bd8107 100644 (file)
@@ -360,6 +360,18 @@ static void amdgpu_uvd_force_into_uvd_segment(struct amdgpu_bo *abo)
        }
 }
 
+static u64 amdgpu_uvd_get_addr_from_ctx(struct amdgpu_uvd_cs_ctx *ctx)
+{
+       uint32_t lo, hi;
+       uint64_t addr;
+
+       lo = amdgpu_get_ib_value(ctx->parser, ctx->ib_idx, ctx->data0);
+       hi = amdgpu_get_ib_value(ctx->parser, ctx->ib_idx, ctx->data1);
+       addr = ((uint64_t)lo) | (((uint64_t)hi) << 32);
+
+       return addr;
+}
+
 /**
  * amdgpu_uvd_cs_pass1 - first parsing round
  *
@@ -372,14 +384,10 @@ static int amdgpu_uvd_cs_pass1(struct amdgpu_uvd_cs_ctx *ctx)
 {
        struct amdgpu_bo_va_mapping *mapping;
        struct amdgpu_bo *bo;
-       uint32_t cmd, lo, hi;
-       uint64_t addr;
+       uint32_t cmd;
+       uint64_t addr = amdgpu_uvd_get_addr_from_ctx(ctx);
        int r = 0;
 
-       lo = amdgpu_get_ib_value(ctx->parser, ctx->ib_idx, ctx->data0);
-       hi = amdgpu_get_ib_value(ctx->parser, ctx->ib_idx, ctx->data1);
-       addr = ((uint64_t)lo) | (((uint64_t)hi) << 32);
-
        mapping = amdgpu_cs_find_mapping(ctx->parser, addr, &bo);
        if (mapping == NULL) {
                DRM_ERROR("Can't find BO for addr 0x%08Lx\n", addr);
@@ -698,15 +706,11 @@ static int amdgpu_uvd_cs_pass2(struct amdgpu_uvd_cs_ctx *ctx)
 {
        struct amdgpu_bo_va_mapping *mapping;
        struct amdgpu_bo *bo;
-       uint32_t cmd, lo, hi;
+       uint32_t cmd;
        uint64_t start, end;
-       uint64_t addr;
+       uint64_t addr = amdgpu_uvd_get_addr_from_ctx(ctx);
        int r;
 
-       lo = amdgpu_get_ib_value(ctx->parser, ctx->ib_idx, ctx->data0);
-       hi = amdgpu_get_ib_value(ctx->parser, ctx->ib_idx, ctx->data1);
-       addr = ((uint64_t)lo) | (((uint64_t)hi) << 32);
-
        mapping = amdgpu_cs_find_mapping(ctx->parser, addr, &bo);
        if (mapping == NULL)
                return -EINVAL;