Skip to content

Commit

Permalink
drm/i915: Share the common force-audio property between connectors
Browse files Browse the repository at this point in the history
Make the audio property creation routine common and share the single
property between the connectors.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
  • Loading branch information
Chris Wilson authored and Keith Packard committed Jun 4, 2011
1 parent 4bce2da commit 3f43c48
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 37 deletions.
1 change: 1 addition & 0 deletions drivers/gpu/drm/i915/i915_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,7 @@ typedef struct drm_i915_private {
struct intel_fbdev *fbdev;

struct drm_property *broadcast_rgb_property;
struct drm_property *force_audio_property;

atomic_t forcewake_count;
} drm_i915_private_t;
Expand Down
15 changes: 2 additions & 13 deletions drivers/gpu/drm/i915/intel_dp.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ struct intel_dp {
bool is_pch_edp;
uint8_t train_set[4];
uint8_t link_status[DP_LINK_STATUS_SIZE];

struct drm_property *force_audio_property;
};

/**
Expand Down Expand Up @@ -1702,7 +1700,7 @@ intel_dp_set_property(struct drm_connector *connector,
if (ret)
return ret;

if (property == intel_dp->force_audio_property) {
if (property == dev_priv->force_audio_property) {
int i = val;
bool has_audio;

Expand Down Expand Up @@ -1841,16 +1839,7 @@ bool intel_dpd_is_edp(struct drm_device *dev)
static void
intel_dp_add_properties(struct intel_dp *intel_dp, struct drm_connector *connector)
{
struct drm_device *dev = connector->dev;

intel_dp->force_audio_property =
drm_property_create(dev, DRM_MODE_PROP_RANGE, "force_audio", 2);
if (intel_dp->force_audio_property) {
intel_dp->force_audio_property->values[0] = -1;
intel_dp->force_audio_property->values[1] = 1;
drm_connector_attach_property(connector, intel_dp->force_audio_property, 0);
}

intel_attach_force_audio_property(connector);
intel_attach_broadcast_rgb_property(connector);
}

Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/i915/intel_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ struct intel_unpin_work {
int intel_ddc_get_modes(struct drm_connector *c, struct i2c_adapter *adapter);
extern bool intel_ddc_probe(struct intel_encoder *intel_encoder, int ddc_bus);

extern void intel_attach_force_audio_property(struct drm_connector *connector);
extern void intel_attach_broadcast_rgb_property(struct drm_connector *connector);

extern void intel_crt_init(struct drm_device *dev);
Expand Down
14 changes: 2 additions & 12 deletions drivers/gpu/drm/i915/intel_hdmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ struct intel_hdmi {
bool has_hdmi_sink;
bool has_audio;
int force_audio;
struct drm_property *force_audio_property;
};

static struct intel_hdmi *enc_to_intel_hdmi(struct drm_encoder *encoder)
Expand Down Expand Up @@ -287,7 +286,7 @@ intel_hdmi_set_property(struct drm_connector *connector,
if (ret)
return ret;

if (property == intel_hdmi->force_audio_property) {
if (property == dev_priv->force_audio_property) {
int i = val;
bool has_audio;

Expand Down Expand Up @@ -365,16 +364,7 @@ static const struct drm_encoder_funcs intel_hdmi_enc_funcs = {
static void
intel_hdmi_add_properties(struct intel_hdmi *intel_hdmi, struct drm_connector *connector)
{
struct drm_device *dev = connector->dev;

intel_hdmi->force_audio_property =
drm_property_create(dev, DRM_MODE_PROP_RANGE, "force_audio", 2);
if (intel_hdmi->force_audio_property) {
intel_hdmi->force_audio_property->values[0] = -1;
intel_hdmi->force_audio_property->values[1] = 1;
drm_connector_attach_property(connector, intel_hdmi->force_audio_property, 0);
}

intel_attach_force_audio_property(connector);
intel_attach_broadcast_rgb_property(connector);
}

Expand Down
30 changes: 30 additions & 0 deletions drivers/gpu/drm/i915/intel_modes.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,36 @@ int intel_ddc_get_modes(struct drm_connector *connector,
return ret;
}

static const char *force_audio_names[] = {
"off",
"auto",
"on",
};

void
intel_attach_force_audio_property(struct drm_connector *connector)
{
struct drm_device *dev = connector->dev;
struct drm_i915_private *dev_priv = dev->dev_private;
struct drm_property *prop;
int i;

prop = dev_priv->force_audio_property;
if (prop == NULL) {
prop = drm_property_create(dev, DRM_MODE_PROP_ENUM,
"audio",
ARRAY_SIZE(force_audio_names));
if (prop == NULL)
return;

for (i = 0; i < ARRAY_SIZE(force_audio_names); i++)
drm_property_add_enum(prop, i, i-1, force_audio_names[i]);

dev_priv->force_audio_property = prop;
}
drm_connector_attach_property(connector, prop, 0);
}

static const char *broadcast_rgb_names[] = {
"Full",
"Limited 16:235",
Expand Down
14 changes: 2 additions & 12 deletions drivers/gpu/drm/i915/intel_sdvo.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,6 @@ struct intel_sdvo_connector {
int format_supported_num;
struct drm_property *tv_format;

struct drm_property *force_audio_property;

/* add the property for the SDVO-TV */
struct drm_property *left;
struct drm_property *right;
Expand Down Expand Up @@ -1712,7 +1710,7 @@ intel_sdvo_set_property(struct drm_connector *connector,
if (ret)
return ret;

if (property == intel_sdvo_connector->force_audio_property) {
if (property == dev_priv->force_audio_property) {
int i = val;
bool has_audio;

Expand Down Expand Up @@ -2037,15 +2035,7 @@ intel_sdvo_add_hdmi_properties(struct intel_sdvo_connector *connector)
{
struct drm_device *dev = connector->base.base.dev;

connector->force_audio_property =
drm_property_create(dev, DRM_MODE_PROP_RANGE, "force_audio", 2);
if (connector->force_audio_property) {
connector->force_audio_property->values[0] = -1;
connector->force_audio_property->values[1] = 1;
drm_connector_attach_property(&connector->base.base,
connector->force_audio_property, 0);
}

intel_attach_force_audio_property(&connector->base.base);
if (INTEL_INFO(dev)->gen >= 4 && IS_MOBILE(dev))
intel_attach_broadcast_rgb_property(&connector->base.base);
}
Expand Down

0 comments on commit 3f43c48

Please sign in to comment.