drm/radeon: use helpers
Signed-off-by: Rob Clark <robdclark@gmail.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
This commit is contained in:
@ -1401,7 +1401,6 @@ int r100_cs_parse_packet0(struct radeon_cs_parser *p,
|
|||||||
*/
|
*/
|
||||||
int r100_cs_packet_parse_vline(struct radeon_cs_parser *p)
|
int r100_cs_packet_parse_vline(struct radeon_cs_parser *p)
|
||||||
{
|
{
|
||||||
struct drm_mode_object *obj;
|
|
||||||
struct drm_crtc *crtc;
|
struct drm_crtc *crtc;
|
||||||
struct radeon_crtc *radeon_crtc;
|
struct radeon_crtc *radeon_crtc;
|
||||||
struct radeon_cs_packet p3reloc, waitreloc;
|
struct radeon_cs_packet p3reloc, waitreloc;
|
||||||
@ -1441,12 +1440,11 @@ int r100_cs_packet_parse_vline(struct radeon_cs_parser *p)
|
|||||||
header = radeon_get_ib_value(p, h_idx);
|
header = radeon_get_ib_value(p, h_idx);
|
||||||
crtc_id = radeon_get_ib_value(p, h_idx + 5);
|
crtc_id = radeon_get_ib_value(p, h_idx + 5);
|
||||||
reg = R100_CP_PACKET0_GET_REG(header);
|
reg = R100_CP_PACKET0_GET_REG(header);
|
||||||
obj = drm_mode_object_find(p->rdev->ddev, crtc_id, DRM_MODE_OBJECT_CRTC);
|
crtc = drm_crtc_find(p->rdev->ddev, crtc_id);
|
||||||
if (!obj) {
|
if (!crtc) {
|
||||||
DRM_ERROR("cannot find crtc %d\n", crtc_id);
|
DRM_ERROR("cannot find crtc %d\n", crtc_id);
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
crtc = obj_to_crtc(obj);
|
|
||||||
radeon_crtc = to_radeon_crtc(crtc);
|
radeon_crtc = to_radeon_crtc(crtc);
|
||||||
crtc_id = radeon_crtc->crtc_id;
|
crtc_id = radeon_crtc->crtc_id;
|
||||||
|
|
||||||
|
@ -825,7 +825,6 @@ int r600_cs_common_vline_parse(struct radeon_cs_parser *p,
|
|||||||
uint32_t *vline_start_end,
|
uint32_t *vline_start_end,
|
||||||
uint32_t *vline_status)
|
uint32_t *vline_status)
|
||||||
{
|
{
|
||||||
struct drm_mode_object *obj;
|
|
||||||
struct drm_crtc *crtc;
|
struct drm_crtc *crtc;
|
||||||
struct radeon_crtc *radeon_crtc;
|
struct radeon_crtc *radeon_crtc;
|
||||||
struct radeon_cs_packet p3reloc, wait_reg_mem;
|
struct radeon_cs_packet p3reloc, wait_reg_mem;
|
||||||
@ -887,12 +886,11 @@ int r600_cs_common_vline_parse(struct radeon_cs_parser *p,
|
|||||||
crtc_id = radeon_get_ib_value(p, h_idx + 2 + 7 + 1);
|
crtc_id = radeon_get_ib_value(p, h_idx + 2 + 7 + 1);
|
||||||
reg = R600_CP_PACKET0_GET_REG(header);
|
reg = R600_CP_PACKET0_GET_REG(header);
|
||||||
|
|
||||||
obj = drm_mode_object_find(p->rdev->ddev, crtc_id, DRM_MODE_OBJECT_CRTC);
|
crtc = drm_crtc_find(p->rdev->ddev, crtc_id);
|
||||||
if (!obj) {
|
if (!crtc) {
|
||||||
DRM_ERROR("cannot find crtc %d\n", crtc_id);
|
DRM_ERROR("cannot find crtc %d\n", crtc_id);
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
crtc = obj_to_crtc(obj);
|
|
||||||
radeon_crtc = to_radeon_crtc(crtc);
|
radeon_crtc = to_radeon_crtc(crtc);
|
||||||
crtc_id = radeon_crtc->crtc_id;
|
crtc_id = radeon_crtc->crtc_id;
|
||||||
|
|
||||||
|
@ -216,7 +216,6 @@ radeon_connector_update_scratch_regs(struct drm_connector *connector, enum drm_c
|
|||||||
struct drm_encoder *best_encoder = NULL;
|
struct drm_encoder *best_encoder = NULL;
|
||||||
struct drm_encoder *encoder = NULL;
|
struct drm_encoder *encoder = NULL;
|
||||||
struct drm_connector_helper_funcs *connector_funcs = connector->helper_private;
|
struct drm_connector_helper_funcs *connector_funcs = connector->helper_private;
|
||||||
struct drm_mode_object *obj;
|
|
||||||
bool connected;
|
bool connected;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -226,14 +225,11 @@ radeon_connector_update_scratch_regs(struct drm_connector *connector, enum drm_c
|
|||||||
if (connector->encoder_ids[i] == 0)
|
if (connector->encoder_ids[i] == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
obj = drm_mode_object_find(connector->dev,
|
encoder = drm_encoder_find(connector->dev,
|
||||||
connector->encoder_ids[i],
|
connector->encoder_ids[i]);
|
||||||
DRM_MODE_OBJECT_ENCODER);
|
if (!encoder)
|
||||||
if (!obj)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
encoder = obj_to_encoder(obj);
|
|
||||||
|
|
||||||
if ((encoder == best_encoder) && (status == connector_status_connected))
|
if ((encoder == best_encoder) && (status == connector_status_connected))
|
||||||
connected = true;
|
connected = true;
|
||||||
else
|
else
|
||||||
@ -249,7 +245,6 @@ radeon_connector_update_scratch_regs(struct drm_connector *connector, enum drm_c
|
|||||||
|
|
||||||
static struct drm_encoder *radeon_find_encoder(struct drm_connector *connector, int encoder_type)
|
static struct drm_encoder *radeon_find_encoder(struct drm_connector *connector, int encoder_type)
|
||||||
{
|
{
|
||||||
struct drm_mode_object *obj;
|
|
||||||
struct drm_encoder *encoder;
|
struct drm_encoder *encoder;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -257,11 +252,10 @@ static struct drm_encoder *radeon_find_encoder(struct drm_connector *connector,
|
|||||||
if (connector->encoder_ids[i] == 0)
|
if (connector->encoder_ids[i] == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
obj = drm_mode_object_find(connector->dev, connector->encoder_ids[i], DRM_MODE_OBJECT_ENCODER);
|
encoder = drm_encoder_find(connector->dev, connector->encoder_ids[i]);
|
||||||
if (!obj)
|
if (!encoder)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
encoder = obj_to_encoder(obj);
|
|
||||||
if (encoder->encoder_type == encoder_type)
|
if (encoder->encoder_type == encoder_type)
|
||||||
return encoder;
|
return encoder;
|
||||||
}
|
}
|
||||||
@ -271,17 +265,9 @@ static struct drm_encoder *radeon_find_encoder(struct drm_connector *connector,
|
|||||||
static struct drm_encoder *radeon_best_single_encoder(struct drm_connector *connector)
|
static struct drm_encoder *radeon_best_single_encoder(struct drm_connector *connector)
|
||||||
{
|
{
|
||||||
int enc_id = connector->encoder_ids[0];
|
int enc_id = connector->encoder_ids[0];
|
||||||
struct drm_mode_object *obj;
|
|
||||||
struct drm_encoder *encoder;
|
|
||||||
|
|
||||||
/* pick the encoder ids */
|
/* pick the encoder ids */
|
||||||
if (enc_id) {
|
if (enc_id)
|
||||||
obj = drm_mode_object_find(connector->dev, enc_id, DRM_MODE_OBJECT_ENCODER);
|
return drm_encoder_find(connector->dev, enc_id);
|
||||||
if (!obj)
|
|
||||||
return NULL;
|
|
||||||
encoder = obj_to_encoder(obj);
|
|
||||||
return encoder;
|
|
||||||
}
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1048,7 +1034,6 @@ radeon_dvi_detect(struct drm_connector *connector, bool force)
|
|||||||
struct radeon_connector *radeon_connector = to_radeon_connector(connector);
|
struct radeon_connector *radeon_connector = to_radeon_connector(connector);
|
||||||
struct drm_encoder *encoder = NULL;
|
struct drm_encoder *encoder = NULL;
|
||||||
struct drm_encoder_helper_funcs *encoder_funcs;
|
struct drm_encoder_helper_funcs *encoder_funcs;
|
||||||
struct drm_mode_object *obj;
|
|
||||||
int i, r;
|
int i, r;
|
||||||
enum drm_connector_status ret = connector_status_disconnected;
|
enum drm_connector_status ret = connector_status_disconnected;
|
||||||
bool dret = false, broken_edid = false;
|
bool dret = false, broken_edid = false;
|
||||||
@ -1153,14 +1138,11 @@ radeon_dvi_detect(struct drm_connector *connector, bool force)
|
|||||||
if (connector->encoder_ids[i] == 0)
|
if (connector->encoder_ids[i] == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
obj = drm_mode_object_find(connector->dev,
|
encoder = drm_encoder_find(connector->dev,
|
||||||
connector->encoder_ids[i],
|
connector->encoder_ids[i]);
|
||||||
DRM_MODE_OBJECT_ENCODER);
|
if (!encoder)
|
||||||
if (!obj)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
encoder = obj_to_encoder(obj);
|
|
||||||
|
|
||||||
if (encoder->encoder_type != DRM_MODE_ENCODER_DAC &&
|
if (encoder->encoder_type != DRM_MODE_ENCODER_DAC &&
|
||||||
encoder->encoder_type != DRM_MODE_ENCODER_TVDAC)
|
encoder->encoder_type != DRM_MODE_ENCODER_TVDAC)
|
||||||
continue;
|
continue;
|
||||||
@ -1225,19 +1207,16 @@ static struct drm_encoder *radeon_dvi_encoder(struct drm_connector *connector)
|
|||||||
{
|
{
|
||||||
int enc_id = connector->encoder_ids[0];
|
int enc_id = connector->encoder_ids[0];
|
||||||
struct radeon_connector *radeon_connector = to_radeon_connector(connector);
|
struct radeon_connector *radeon_connector = to_radeon_connector(connector);
|
||||||
struct drm_mode_object *obj;
|
|
||||||
struct drm_encoder *encoder;
|
struct drm_encoder *encoder;
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) {
|
for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) {
|
||||||
if (connector->encoder_ids[i] == 0)
|
if (connector->encoder_ids[i] == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
obj = drm_mode_object_find(connector->dev, connector->encoder_ids[i], DRM_MODE_OBJECT_ENCODER);
|
encoder = drm_encoder_find(connector->dev, connector->encoder_ids[i]);
|
||||||
if (!obj)
|
if (!encoder)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
encoder = obj_to_encoder(obj);
|
|
||||||
|
|
||||||
if (radeon_connector->use_digital == true) {
|
if (radeon_connector->use_digital == true) {
|
||||||
if (encoder->encoder_type == DRM_MODE_ENCODER_TMDS)
|
if (encoder->encoder_type == DRM_MODE_ENCODER_TMDS)
|
||||||
return encoder;
|
return encoder;
|
||||||
@ -1252,13 +1231,8 @@ static struct drm_encoder *radeon_dvi_encoder(struct drm_connector *connector)
|
|||||||
|
|
||||||
/* then check use digitial */
|
/* then check use digitial */
|
||||||
/* pick the first one */
|
/* pick the first one */
|
||||||
if (enc_id) {
|
if (enc_id)
|
||||||
obj = drm_mode_object_find(connector->dev, enc_id, DRM_MODE_OBJECT_ENCODER);
|
return drm_encoder_find(connector->dev, enc_id);
|
||||||
if (!obj)
|
|
||||||
return NULL;
|
|
||||||
encoder = obj_to_encoder(obj);
|
|
||||||
return encoder;
|
|
||||||
}
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1391,7 +1365,6 @@ static int radeon_dp_get_modes(struct drm_connector *connector)
|
|||||||
|
|
||||||
u16 radeon_connector_encoder_get_dp_bridge_encoder_id(struct drm_connector *connector)
|
u16 radeon_connector_encoder_get_dp_bridge_encoder_id(struct drm_connector *connector)
|
||||||
{
|
{
|
||||||
struct drm_mode_object *obj;
|
|
||||||
struct drm_encoder *encoder;
|
struct drm_encoder *encoder;
|
||||||
struct radeon_encoder *radeon_encoder;
|
struct radeon_encoder *radeon_encoder;
|
||||||
int i;
|
int i;
|
||||||
@ -1400,11 +1373,10 @@ u16 radeon_connector_encoder_get_dp_bridge_encoder_id(struct drm_connector *conn
|
|||||||
if (connector->encoder_ids[i] == 0)
|
if (connector->encoder_ids[i] == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
obj = drm_mode_object_find(connector->dev, connector->encoder_ids[i], DRM_MODE_OBJECT_ENCODER);
|
encoder = drm_encoder_find(connector->dev, connector->encoder_ids[i]);
|
||||||
if (!obj)
|
if (!encoder)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
encoder = obj_to_encoder(obj);
|
|
||||||
radeon_encoder = to_radeon_encoder(encoder);
|
radeon_encoder = to_radeon_encoder(encoder);
|
||||||
|
|
||||||
switch (radeon_encoder->encoder_id) {
|
switch (radeon_encoder->encoder_id) {
|
||||||
@ -1421,7 +1393,6 @@ u16 radeon_connector_encoder_get_dp_bridge_encoder_id(struct drm_connector *conn
|
|||||||
|
|
||||||
bool radeon_connector_encoder_is_hbr2(struct drm_connector *connector)
|
bool radeon_connector_encoder_is_hbr2(struct drm_connector *connector)
|
||||||
{
|
{
|
||||||
struct drm_mode_object *obj;
|
|
||||||
struct drm_encoder *encoder;
|
struct drm_encoder *encoder;
|
||||||
struct radeon_encoder *radeon_encoder;
|
struct radeon_encoder *radeon_encoder;
|
||||||
int i;
|
int i;
|
||||||
@ -1431,11 +1402,10 @@ bool radeon_connector_encoder_is_hbr2(struct drm_connector *connector)
|
|||||||
if (connector->encoder_ids[i] == 0)
|
if (connector->encoder_ids[i] == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
obj = drm_mode_object_find(connector->dev, connector->encoder_ids[i], DRM_MODE_OBJECT_ENCODER);
|
encoder = drm_encoder_find(connector->dev, connector->encoder_ids[i]);
|
||||||
if (!obj)
|
if (!encoder)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
encoder = obj_to_encoder(obj);
|
|
||||||
radeon_encoder = to_radeon_encoder(encoder);
|
radeon_encoder = to_radeon_encoder(encoder);
|
||||||
if (radeon_encoder->caps & ATOM_ENCODER_CAP_RECORD_HBR2)
|
if (radeon_encoder->caps & ATOM_ENCODER_CAP_RECORD_HBR2)
|
||||||
found = true;
|
found = true;
|
||||||
|
Reference in New Issue
Block a user