freedreno: small refactor for get_param
Will simplify next commit. Signed-off-by: Rob Clark <robclark@freedesktop.org>main
parent
c47385ccda
commit
bc5497d061
|
@ -32,6 +32,25 @@
|
||||||
|
|
||||||
#include "msm_priv.h"
|
#include "msm_priv.h"
|
||||||
|
|
||||||
|
static int query_param(struct fd_pipe *pipe, uint32_t param,
|
||||||
|
uint64_t *value)
|
||||||
|
{
|
||||||
|
struct msm_pipe *msm_pipe = to_msm_pipe(pipe);
|
||||||
|
struct drm_msm_param req = {
|
||||||
|
.pipe = msm_pipe->pipe,
|
||||||
|
.param = param,
|
||||||
|
};
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = drmCommandWriteRead(pipe->dev->fd, DRM_MSM_GET_PARAM,
|
||||||
|
&req, sizeof(req));
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
*value = req.value;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int msm_pipe_get_param(struct fd_pipe *pipe,
|
static int msm_pipe_get_param(struct fd_pipe *pipe,
|
||||||
enum fd_param_id param, uint64_t *value)
|
enum fd_param_id param, uint64_t *value)
|
||||||
|
@ -87,21 +106,15 @@ static const struct fd_pipe_funcs funcs = {
|
||||||
.destroy = msm_pipe_destroy,
|
.destroy = msm_pipe_destroy,
|
||||||
};
|
};
|
||||||
|
|
||||||
static uint64_t get_param(struct fd_device *dev, uint32_t pipe, uint32_t param)
|
static uint64_t get_param(struct fd_pipe *pipe, uint32_t param)
|
||||||
{
|
{
|
||||||
struct drm_msm_param req = {
|
uint64_t value;
|
||||||
.pipe = pipe,
|
int ret = query_param(pipe, param, &value);
|
||||||
.param = param,
|
|
||||||
};
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = drmCommandWriteRead(dev->fd, DRM_MSM_GET_PARAM, &req, sizeof(req));
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
ERROR_MSG("get-param failed! %d (%s)", ret, strerror(errno));
|
ERROR_MSG("get-param failed! %d (%s)", ret, strerror(errno));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
return value;
|
||||||
return req.value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
drm_private struct fd_pipe * msm_pipe_new(struct fd_device *dev,
|
drm_private struct fd_pipe * msm_pipe_new(struct fd_device *dev,
|
||||||
|
@ -123,10 +136,14 @@ drm_private struct fd_pipe * msm_pipe_new(struct fd_device *dev,
|
||||||
pipe = &msm_pipe->base;
|
pipe = &msm_pipe->base;
|
||||||
pipe->funcs = &funcs;
|
pipe->funcs = &funcs;
|
||||||
|
|
||||||
|
/* initialize before get_param(): */
|
||||||
|
pipe->dev = dev;
|
||||||
msm_pipe->pipe = pipe_id[id];
|
msm_pipe->pipe = pipe_id[id];
|
||||||
msm_pipe->gpu_id = get_param(dev, pipe_id[id], MSM_PARAM_GPU_ID);
|
|
||||||
msm_pipe->gmem = get_param(dev, pipe_id[id], MSM_PARAM_GMEM_SIZE);
|
/* these params should be supported since the first version of drm/msm: */
|
||||||
msm_pipe->chip_id = get_param(dev, pipe_id[id], MSM_PARAM_CHIP_ID);
|
msm_pipe->gpu_id = get_param(pipe, MSM_PARAM_GPU_ID);
|
||||||
|
msm_pipe->gmem = get_param(pipe, MSM_PARAM_GMEM_SIZE);
|
||||||
|
msm_pipe->chip_id = get_param(pipe, MSM_PARAM_CHIP_ID);
|
||||||
|
|
||||||
if (! msm_pipe->gpu_id)
|
if (! msm_pipe->gpu_id)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
Loading…
Reference in New Issue