int ret;
struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
- ret = EINVAL;
+ ret = EINVAL;
- DRM_DEBUG_KMS(
- "%s: crtc_id=%d with size %d to %d \n",
- __func__,
- amdgpu_crtc->crtc_id,
- width,
- height);
+ DRM_DEBUG_KMS("%s: crtc_id=%d with size %d to %d \n",
+ __func__,
+ amdgpu_crtc->crtc_id,
+ width,
+ height);
if (!address) {
/* turn off cursor */
{
struct amdgpu_bo *rbo = gem_to_amdgpu_bo(amdgpu_fb->obj);
int r = amdgpu_bo_reserve(rbo, false);
+
if (unlikely(r)) {
DRM_ERROR("Unable to reserve buffer\n");
return r;
memset(&surface->tiling_info, 0, sizeof(surface->tiling_info));
- /* Fill GFX params */
- if (AMDGPU_TILING_GET(tiling_flags, ARRAY_MODE) == DC_ARRAY_2D_TILED_THIN1)
- {
- unsigned bankw, bankh, mtaspect, tile_split, num_banks;
+ /* Fill GFX8 params */
+ if (AMDGPU_TILING_GET(tiling_flags, ARRAY_MODE) == DC_ARRAY_2D_TILED_THIN1) {
+ unsigned int bankw, bankh, mtaspect, tile_split, num_banks;
bankw = AMDGPU_TILING_GET(tiling_flags, BANK_WIDTH);
bankh = AMDGPU_TILING_GET(tiling_flags, BANK_HEIGHT);
uint32_t bpc = connector->display_info.bpc;
/* Limited color depth to 8bit
- * TODO: Still need to handle deep color*/
+ * TODO: Still need to handle deep color
+ */
if (bpc > 8)
bpc = 8;
{
int32_t width = mode_in->crtc_hdisplay * 9;
int32_t height = mode_in->crtc_vdisplay * 16;
+
if ((width - height) < 10 && (width - height) > -10)
return ASPECT_RATIO_16_9;
else
const struct drm_connector *connector)
{
struct dc_crtc_timing *timing_out = &stream->timing;
+
memset(timing_out, 0, sizeof(struct dc_crtc_timing));
timing_out->h_border_left = 0;
{
struct dc_transfer_func *tf = dc_create_transfer_func();
+
tf->type = TF_TYPE_PREDEFINED;
tf->tf = TRANSFER_FUNCTION_SRGB;
stream->out_transfer_func = tf;
i++;
}
- if(cea_revision >= 3) {
+ if (cea_revision >= 3) {
audio_info->mode_count = edid_caps->audio_mode_count;
for (i = 0; i < audio_info->mode_count; ++i) {
audio_info->flags.all = edid_caps->speaker_flags;
/* TODO: We only check for the progressive mode, check for interlace mode too */
- if(drm_connector->latency_present[0]) {
+ if (drm_connector->latency_present[0]) {
audio_info->video_latency = drm_connector->video_latency[0];
audio_info->audio_latency = drm_connector->audio_latency[0];
}
dst_mode->crtc_clock = src_mode->crtc_clock;
dst_mode->crtc_hblank_start = src_mode->crtc_hblank_start;
dst_mode->crtc_hblank_end = src_mode->crtc_hblank_end;
- dst_mode->crtc_hsync_start= src_mode->crtc_hsync_start;
+ dst_mode->crtc_hsync_start = src_mode->crtc_hsync_start;
dst_mode->crtc_hsync_end = src_mode->crtc_hsync_end;
dst_mode->crtc_htotal = src_mode->crtc_htotal;
dst_mode->crtc_hskew = src_mode->crtc_hskew;
struct drm_display_mode mode = *drm_mode;
bool native_mode_found = false;
- if (NULL == aconnector) {
+ if (aconnector == NULL) {
DRM_ERROR("aconnector is NULL!\n");
goto drm_connector_null;
}
- if (NULL == dm_state) {
+ if (dm_state == NULL) {
DRM_ERROR("dm_state is NULL!\n");
goto dm_state_null;
}
drm_connector = &aconnector->base;
stream = dc_create_stream_for_sink(aconnector->dc_sink);
- if (NULL == stream) {
+ if (stream == NULL) {
DRM_ERROR("Failed to create stream for sink!\n");
goto stream_create_fail;
}
struct drm_display_mode,
head);
- if (NULL == preferred_mode) {
+ if (preferred_mode == NULL) {
/* This may not be an error, the use case is when we we have no
* usermode calls to reset and set mode upon hotplug. In this
* case, we call set mode ourselves to restore the previous mode
dc_sink = to_amdgpu_connector(connector)->dc_sink;
- if (NULL == dc_sink) {
+ if (dc_sink == NULL) {
DRM_ERROR("dc_sink is NULL!\n");
goto fail;
}
stream = dc_create_stream_for_sink(dc_sink);
- if (NULL == stream) {
+ if (stream == NULL) {
DRM_ERROR("Failed to create stream for sink!\n");
goto fail;
}
static const struct drm_connector_helper_funcs
amdgpu_dm_connector_helper_funcs = {
/*
- * If hotplug a second bigger display in FB Con mode, bigger resolution
- * modes will be filtered by drm_mode_validate_size(), and those modes
- * is missing after user start lightdm. So we need to renew modes list.
- * in get_modes call back, not just return the modes count
- */
+ * If hotplug a second bigger display in FB Con mode, bigger resolution
+ * modes will be filtered by drm_mode_validate_size(), and those modes
+ * is missing after user start lightdm. So we need to renew modes list.
+ * in get_modes call back, not just return the modes count
+ */
.get_modes = get_modes,
.mode_valid = amdgpu_dm_connector_mode_valid,
.best_encoder = best_encoder
if (unlikely(r)) {
DRM_ERROR("failed to reserve rbo before unpin\n");
return;
- } else {
- amdgpu_bo_unpin(rbo);
- amdgpu_bo_unreserve(rbo);
- amdgpu_bo_unref(&rbo);
- };
+ }
+
+ amdgpu_bo_unpin(rbo);
+ amdgpu_bo_unreserve(rbo);
+ amdgpu_bo_unref(&rbo);
}
int dm_create_validation_set_for_connector(struct drm_connector *connector,
(mode->flags & DRM_MODE_FLAG_DBLSCAN))
return result;
- if (NULL == dc_sink) {
+ if (dc_sink == NULL) {
DRM_ERROR("dc_sink is NULL!\n");
return result;
}
stream = dc_create_stream_for_sink(dc_sink);
- if (NULL == stream) {
+ if (stream == NULL) {
DRM_ERROR("Failed to create stream for sink!\n");
return result;
}
return 0;
fail:
- if (acrtc)
- kfree(acrtc);
- if (cursor_plane)
- kfree(cursor_plane);
+ kfree(acrtc);
+ kfree(cursor_plane);
acrtc->crtc_id = -1;
return res;
}
if (!list_empty(&connector->probed_modes)) {
struct drm_display_mode *preferred_mode = NULL;
+
list_for_each_entry(preferred_mode,
- &connector->probed_modes,
- head) {
- if (preferred_mode->type & DRM_MODE_TYPE_PREFERRED) {
- amdgpu_encoder->native_mode = *preferred_mode;
- }
+ &connector->probed_modes,
+ head) {
+ if (preferred_mode->type & DRM_MODE_TYPE_PREFERRED)
+ amdgpu_encoder->native_mode = *preferred_mode;
+
break;
}
mode = drm_mode_duplicate(dev, native_mode);
- if(mode == NULL)
+ if (mode == NULL)
return NULL;
mode->hdisplay = hdisplay;
char name[DRM_DISPLAY_MODE_LEN];
int w;
int h;
- }common_modes[] = {
+ } common_modes[] = {
{ "640x480", 640, 480},
{ "800x600", 800, 600},
{ "1024x768", 1024, 768},
{"1920x1200", 1920, 1200}
};
- n = sizeof(common_modes) / sizeof(common_modes[0]);
+ n = ARRAY_SIZE(common_modes);
for (i = 0; i < n; i++) {
struct drm_display_mode *curmode = NULL;
bool mode_existed = false;
if (common_modes[i].w > native_mode->hdisplay ||
- common_modes[i].h > native_mode->vdisplay ||
- (common_modes[i].w == native_mode->hdisplay &&
- common_modes[i].h == native_mode->vdisplay))
- continue;
+ common_modes[i].h > native_mode->vdisplay ||
+ (common_modes[i].w == native_mode->hdisplay &&
+ common_modes[i].h == native_mode->vdisplay))
+ continue;
list_for_each_entry(curmode, &connector->probed_modes, head) {
if (common_modes[i].w == curmode->hdisplay &&
- common_modes[i].h == curmode->vdisplay) {
+ common_modes[i].h == curmode->vdisplay) {
mode_existed = true;
break;
}
mutex_init(&aconnector->hpd_lock);
- /*configure suport HPD hot plug connector_>polled default value is 0
- * which means HPD hot plug not supported*/
+ /* configure support HPD hot plug connector_>polled default value is 0
+ * which means HPD hot plug not supported
+ */
switch (connector_type) {
case DRM_MODE_CONNECTOR_HDMIA:
aconnector->base.polled = DRM_CONNECTOR_POLL_HPD;
int i;
int result = -EIO;
- cmd.payloads = kzalloc(num * sizeof(struct i2c_payload), GFP_KERNEL);
+ cmd.payloads = kcalloc(num, sizeof(struct i2c_payload), GFP_KERNEL);
if (!cmd.payloads)
return result;
struct amdgpu_device *adev = ddc_service->ctx->driver_context;
struct amdgpu_i2c_adapter *i2c;
- i2c = kzalloc(sizeof (struct amdgpu_i2c_adapter), GFP_KERNEL);
+ i2c = kzalloc(sizeof(struct amdgpu_i2c_adapter), GFP_KERNEL);
i2c->base.owner = THIS_MODULE;
i2c->base.class = I2C_CLASS_DDC;
i2c->base.dev.parent = &adev->pdev->dev;
i2c->base.algo = &amdgpu_dm_i2c_algo;
- snprintf(i2c->base.name, sizeof (i2c->base.name), "AMDGPU DM i2c hw bus %d", link_index);
+ snprintf(i2c->base.name, sizeof(i2c->base.name), "AMDGPU DM i2c hw bus %d", link_index);
i2c_set_adapdata(&i2c->base, i2c);
i2c->ddc_service = ddc_service;
}
/* Note: this function assumes that dc_link_detect() was called for the
- * dc_link which will be represented by this aconnector. */
+ * dc_link which will be represented by this aconnector.
+ */
int amdgpu_dm_connector_init(
struct amdgpu_display_manager *dm,
struct amdgpu_connector *aconnector,
if (link->connector_signal & (SIGNAL_TYPE_EDP | SIGNAL_TYPE_LVDS)) {
/* Event if registration failed, we should continue with
* DM initialization because not having a backlight control
- * is better then a black screen. */
+ * is better then a black screen.
+ */
amdgpu_dm_register_backlight_device(dm);
if (dm->backlight_dev)
} else if (dm_state->underscan_enable && !old_dm_state->underscan_enable) {
if (dm_state->underscan_hborder != 0 && dm_state->underscan_vborder != 0)
return true;
- } else if (dm_state->underscan_hborder != old_dm_state->underscan_hborder
- || dm_state->underscan_vborder != old_dm_state->underscan_vborder)
- return true;
+ } else if (dm_state->underscan_hborder != old_dm_state->underscan_hborder ||
+ dm_state->underscan_vborder != old_dm_state->underscan_vborder)
+ return true;
return false;
}
target_vblank = target - drm_crtc_vblank_count(crtc) +
amdgpu_get_vblank_counter_kms(crtc->dev, acrtc->crtc_id);
- /*TODO This might fail and hence better not used, wait
+ /* TODO This might fail and hence better not used, wait
* explicitly on fences instead
* and in general should be called for
* blocking commit to as per framework helpers
- * */
+ */
r = amdgpu_bo_reserve(abo, true);
if (unlikely(r != 0)) {
DRM_ERROR("failed to reserve buffer before flip\n");
DRM_ERROR("add_surface: acrtc %d, already busy\n",
acrtc_attach->crtc_id);
spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
- /* In comit tail framework this cannot happen */
+ /* In commit tail framework this cannot happen */
WARN_ON(1);
}
spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
for_each_crtc_in_state(state, crtc, old_crtc_state, i) {
struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
struct drm_crtc_state *new_state = crtc->state;
+
new_acrtc_state = to_dm_crtc_state(new_state);
old_acrtc_state = to_dm_crtc_state(old_crtc_state);
if (!new_acrtc_state->stream) {
/*
- * this could happen because of issues with
- * userspace notifications delivery.
- * In this case userspace tries to set mode on
- * display which is disconnect in fact.
- * dc_sink in NULL in this case on aconnector.
- * We expect reset mode will come soon.
- *
- * This can also happen when unplug is done
- * during resume sequence ended
- *
- * In this case, we want to pretend we still
- * have a sink to keep the pipe running so that
- * hw state is consistent with the sw state
- */
+ * this could happen because of issues with
+ * userspace notifications delivery.
+ * In this case userspace tries to set mode on
+ * display which is disconnect in fact.
+ * dc_sink in NULL in this case on aconnector.
+ * We expect reset mode will come soon.
+ *
+ * This can also happen when unplug is done
+ * during resume sequence ended
+ *
+ * In this case, we want to pretend we still
+ * have a sink to keep the pipe running so that
+ * hw state is consistent with the sw state
+ */
DRM_DEBUG_KMS("%s: Failed to create new stream for crtc %d\n",
__func__, acrtc->base.base.id);
continue;
if (adev->dm.freesync_module) {
for (i = 0; i < new_crtcs_count; i++) {
struct amdgpu_connector *aconnector = NULL;
+
new_acrtc_state = to_dm_crtc_state(new_crtcs[i]->base.state);
new_stream = new_acrtc_state->stream;
&new_crtcs[i]->base,
false);
if (!aconnector) {
- DRM_INFO(
- "Atomic commit: Failed to find connector for acrtc id:%d "
- "skipping freesync init\n",
- new_crtcs[i]->crtc_id);
+ DRM_INFO("Atomic commit: Failed to find connector for acrtc id:%d "
+ "skipping freesync init\n",
+ new_crtcs[i]->crtc_id);
continue;
}
list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
+
new_acrtc_state = to_dm_crtc_state(crtc->state);
if (new_acrtc_state->stream != NULL) {
* loop to enable interrupts on newly arrived crtc
*/
struct amdgpu_crtc *acrtc = new_crtcs[i];
+
new_acrtc_state = to_dm_crtc_state(acrtc->base.state);
if (adev->dm.freesync_module)
set_count--;
- for (; i < set_count; i++) {
+ for (; i < set_count; i++)
val_sets[i] = val_sets[i + 1];
- }
return set_count;
}
if (ret == 0)
DRM_ERROR("[CRTC:%d:%s] hw_done or flip_done "
- "timed out\n", crtc->base.id, crtc->name);
+ "timed out\n", crtc->base.id, crtc->name);
drm_crtc_commit_put(commit);
}
for_each_crtc_in_state(state, crtc, crtc_state, i) {
struct amdgpu_crtc *acrtc = NULL;
struct amdgpu_connector *aconnector = NULL;
+
old_acrtc_state = to_dm_crtc_state(crtc->state);
new_acrtc_state = to_dm_crtc_state(crtc_state);
acrtc = to_amdgpu_crtc(crtc);
if (!acrtc || drm_atomic_crtc_needs_modeset(acrtc->base.state))
continue;
- /* Skip any thing not scale or underscan chnages */
+ /* Skip any thing not scale or underscan changes */
if (!is_scaling_state_different(con_new_state, con_old_state))
continue;
struct drm_device *dev = connector->dev;
struct amdgpu_device *adev = dev->dev_private;
+
edid_check_required = false;
if (!amdgpu_connector->dc_sink) {
DRM_ERROR("dc_sink NULL, could not add free_sync module.\n");