diff options
Diffstat (limited to 'freedreno/msm/msm_pipe.c')
-rw-r--r-- | freedreno/msm/msm_pipe.c | 47 |
1 files changed, 34 insertions, 13 deletions
diff --git a/freedreno/msm/msm_pipe.c b/freedreno/msm/msm_pipe.c index aa0866b4..f872e245 100644 --- a/freedreno/msm/msm_pipe.c +++ b/freedreno/msm/msm_pipe.c | |||
@@ -32,6 +32,25 @@ | |||
32 | 32 | ||
33 | #include "msm_priv.h" | 33 | #include "msm_priv.h" |
34 | 34 | ||
35 | static int query_param(struct fd_pipe *pipe, uint32_t param, | ||
36 | uint64_t *value) | ||
37 | { | ||
38 | struct msm_pipe *msm_pipe = to_msm_pipe(pipe); | ||
39 | struct drm_msm_param req = { | ||
40 | .pipe = msm_pipe->pipe, | ||
41 | .param = param, | ||
42 | }; | ||
43 | int ret; | ||
44 | |||
45 | ret = drmCommandWriteRead(pipe->dev->fd, DRM_MSM_GET_PARAM, | ||
46 | &req, sizeof(req)); | ||
47 | if (ret) | ||
48 | return ret; | ||
49 | |||
50 | *value = req.value; | ||
51 | |||
52 | return 0; | ||
53 | } | ||
35 | 54 | ||
36 | static int msm_pipe_get_param(struct fd_pipe *pipe, | 55 | static int msm_pipe_get_param(struct fd_pipe *pipe, |
37 | enum fd_param_id param, uint64_t *value) | 56 | enum fd_param_id param, uint64_t *value) |
@@ -48,6 +67,10 @@ static int msm_pipe_get_param(struct fd_pipe *pipe, | |||
48 | case FD_CHIP_ID: | 67 | case FD_CHIP_ID: |
49 | *value = msm_pipe->chip_id; | 68 | *value = msm_pipe->chip_id; |
50 | return 0; | 69 | return 0; |
70 | case FD_MAX_FREQ: | ||
71 | return query_param(pipe, MSM_PARAM_MAX_FREQ, value); | ||
72 | case FD_TIMESTAMP: | ||
73 | return query_param(pipe, MSM_PARAM_TIMESTAMP, value); | ||
51 | default: | 74 | default: |
52 | ERROR_MSG("invalid param id: %d", param); | 75 | ERROR_MSG("invalid param id: %d", param); |
53 | return -1; | 76 | return -1; |
@@ -87,21 +110,15 @@ static const struct fd_pipe_funcs funcs = { | |||
87 | .destroy = msm_pipe_destroy, | 110 | .destroy = msm_pipe_destroy, |
88 | }; | 111 | }; |
89 | 112 | ||
90 | static uint64_t get_param(struct fd_device *dev, uint32_t pipe, uint32_t param) | 113 | static uint64_t get_param(struct fd_pipe *pipe, uint32_t param) |
91 | { | 114 | { |
92 | struct drm_msm_param req = { | 115 | uint64_t value; |
93 | .pipe = pipe, | 116 | int ret = query_param(pipe, param, &value); |
94 | .param = param, | ||
95 | }; | ||
96 | int ret; | ||
97 | |||
98 | ret = drmCommandWriteRead(dev->fd, DRM_MSM_GET_PARAM, &req, sizeof(req)); | ||
99 | if (ret) { | 117 | if (ret) { |
100 | ERROR_MSG("get-param failed! %d (%s)", ret, strerror(errno)); | 118 | ERROR_MSG("get-param failed! %d (%s)", ret, strerror(errno)); |
101 | return 0; | 119 | return 0; |
102 | } | 120 | } |
103 | 121 | return value; | |
104 | return req.value; | ||
105 | } | 122 | } |
106 | 123 | ||
107 | drm_private struct fd_pipe * msm_pipe_new(struct fd_device *dev, | 124 | drm_private struct fd_pipe * msm_pipe_new(struct fd_device *dev, |
@@ -123,10 +140,14 @@ drm_private struct fd_pipe * msm_pipe_new(struct fd_device *dev, | |||
123 | pipe = &msm_pipe->base; | 140 | pipe = &msm_pipe->base; |
124 | pipe->funcs = &funcs; | 141 | pipe->funcs = &funcs; |
125 | 142 | ||
143 | /* initialize before get_param(): */ | ||
144 | pipe->dev = dev; | ||
126 | msm_pipe->pipe = pipe_id[id]; | 145 | msm_pipe->pipe = pipe_id[id]; |
127 | msm_pipe->gpu_id = get_param(dev, pipe_id[id], MSM_PARAM_GPU_ID); | 146 | |
128 | msm_pipe->gmem = get_param(dev, pipe_id[id], MSM_PARAM_GMEM_SIZE); | 147 | /* these params should be supported since the first version of drm/msm: */ |
129 | msm_pipe->chip_id = get_param(dev, pipe_id[id], MSM_PARAM_CHIP_ID); | 148 | msm_pipe->gpu_id = get_param(pipe, MSM_PARAM_GPU_ID); |
149 | msm_pipe->gmem = get_param(pipe, MSM_PARAM_GMEM_SIZE); | ||
150 | msm_pipe->chip_id = get_param(pipe, MSM_PARAM_CHIP_ID); | ||
130 | 151 | ||
131 | if (! msm_pipe->gpu_id) | 152 | if (! msm_pipe->gpu_id) |
132 | goto fail; | 153 | goto fail; |