Lines Matching +full:disable +full:- +full:dc

1 /*-
58 #define WR4(_sc, _r, _v) bus_write_4((_sc)->mem_res, 4 * (_r), (_v))
59 #define RD4(_sc, _r) bus_read_4((_sc)->mem_res, 4 * (_r))
205 {"nvidia,tegra124-hdmi", 1},
225 return -EINVAL; in drm_hdmi_avi_infoframe_from_display_mode()
231 if (mode->flags & DRM_MODE_FLAG_DBLCLK) in drm_hdmi_avi_infoframe_from_display_mode()
232 frame->pixel_repeat = 1; in drm_hdmi_avi_infoframe_from_display_mode()
234 frame->video_code = drm_match_cea_mode(mode); in drm_hdmi_avi_infoframe_from_display_mode()
236 frame->picture_aspect = HDMI_PICTURE_ASPECT_NONE; in drm_hdmi_avi_infoframe_from_display_mode()
242 if (mode->picture_aspect_ratio == HDMI_PICTURE_ASPECT_4_3 || in drm_hdmi_avi_infoframe_from_display_mode()
243 mode->picture_aspect_ratio == HDMI_PICTURE_ASPECT_16_9) in drm_hdmi_avi_infoframe_from_display_mode()
244 frame->picture_aspect = mode->picture_aspect_ratio; in drm_hdmi_avi_infoframe_from_display_mode()
245 else if (frame->video_code > 0) in drm_hdmi_avi_infoframe_from_display_mode()
246 frame->picture_aspect = drm_get_cea_aspect_ratio( in drm_hdmi_avi_infoframe_from_display_mode()
247 frame->video_code); in drm_hdmi_avi_infoframe_from_display_mode()
250 frame->active_aspect = HDMI_ACTIVE_ASPECT_PICTURE; in drm_hdmi_avi_infoframe_from_display_mode()
251 frame->scan_mode = HDMI_SCAN_MODE_UNDERSCAN; in drm_hdmi_avi_infoframe_from_display_mode()
255 /* --------------------------------------------------------------------- */
264 sc = device_get_softc(output->dev); in hdmi_setup_clock()
266 /* Disable consumers clock for while. */ in hdmi_setup_clock()
267 rv = clk_disable(sc->clk_hdmi); in hdmi_setup_clock()
269 device_printf(sc->dev, "Cannot disable 'hdmi' clock\n"); in hdmi_setup_clock()
274 device_printf(sc->dev, "Cannot disable display clock\n"); in hdmi_setup_clock()
280 rv = clk_set_freq(sc->clk_parent, freq, 0); in hdmi_setup_clock()
282 device_printf(output->dev, in hdmi_setup_clock()
288 rv = clk_set_parent_by_clk(clk, sc->clk_parent); in hdmi_setup_clock()
290 device_printf(output->dev, "Cannot set parent clock\n"); in hdmi_setup_clock()
295 device_printf(output->dev, in hdmi_setup_clock()
299 rv = clk_set_freq(sc->clk_hdmi, pclk, 0); in hdmi_setup_clock()
301 device_printf(output->dev, in hdmi_setup_clock()
309 device_printf(sc->dev, "Cannot enable display clock\n"); in hdmi_setup_clock()
312 rv = clk_enable(sc->clk_hdmi); in hdmi_setup_clock()
314 device_printf(sc->dev, "Cannot enable 'hdmi' clock\n"); in hdmi_setup_clock()
320 device_printf(output->dev, in hdmi_setup_clock()
325 DRM_DEBUG_KMS("DC frequency: %llu\n", freq); in hdmi_setup_clock()
330 /* -------------------------------------------------------------------
344 device_printf(sc->dev, "Cannot setup AVI infoframe: %zd\n", rv); in avi_setup_infoframe()
349 device_printf(sc->dev, "Cannot pack AVI infoframe: %zd\n", rv); in avi_setup_infoframe()
377 frame.channels = sc->audio_chans; in audio_setup_infoframe()
380 device_printf(sc->dev, "Cannot pack audio infoframe\n"); in audio_setup_infoframe()
396 /* -------------------------------------------------------------------
408 size = drm_eld_size(sc->output.connector.eld); in init_hda_eld()
412 val |= sc->output.connector.eld[i]; in init_hda_eld()
428 if (reg->audio_clk == freq) { in get_audio_regs()
430 *acr_reg = reg->acr_reg; in get_audio_regs()
432 *nval_reg = reg->nval_reg; in get_audio_regs()
434 *aval_reg = reg->aval_reg; in get_audio_regs()
482 err_f = cts_f - TO_FFP(cts); in get_hda_cts_n()
484 err_f = -err_f; in get_hda_cts_n()
490 better_n = abs(n - ideal_n) < abs((int)(*best_n) - ideal_n); in get_hda_cts_n()
519 if (!sc->hdmi_mode) in audio_setup()
521 rv = get_audio_regs(sc->audio_freq, NULL, NULL, &aval_reg); in audio_setup()
523 device_printf(sc->dev, "Unsupported audio frequency.\n"); in audio_setup()
527 rv = clk_get_freq(sc->clk_hdmi, &hdmi_freq); in audio_setup()
529 device_printf(sc->dev, "Cannot get hdmi frequency: %d\n", rv); in audio_setup()
533 rv = get_hda_cts_n(sc->audio_freq, hdmi_freq, &audio_cts, &audio_n, in audio_setup()
536 device_printf(sc->dev, "Cannot compute audio coefs: %d\n", rv); in audio_setup()
544 SOR_AUDIO_CNTRL0_SOURCE_SELECT(sc->audio_src_type) | in audio_setup()
556 AUDIO_N_VALUE(audio_n - 1)); in audio_setup()
580 /* Disable audio */ in audio_disable()
585 /* Disable audio infoframes */ in audio_disable()
595 if (!sc->hdmi_mode) in audio_enable()
609 /* -------------------------------------------------------------------
621 if (!sc->hdmi_mode) in hda_intr()
632 sc->audio_freq = val & 0x00FFFFFF; in hda_intr()
633 sc->audio_chans = (val >> 24) & 0x0f; in hda_intr()
634 DRM_DEBUG_KMS("%d channel(s) at %dHz\n", sc->audio_chans, in hda_intr()
635 sc->audio_freq); in hda_intr()
650 WR4(sc, HDMI_NV_PDISP_SOR_PLL0, tmds->pll0); in tmds_init()
651 WR4(sc, HDMI_NV_PDISP_SOR_PLL1, tmds->pll1); in tmds_init()
652 WR4(sc, HDMI_NV_PDISP_PE_CURRENT, tmds->pe_c); in tmds_init()
653 WR4(sc, HDMI_NV_PDISP_SOR_LANE_DRIVE_CURRENT, tmds->drive_c); in tmds_init()
654 WR4(sc, HDMI_NV_PDISP_SOR_IO_PEAK_CURRENT, tmds->peak_c); in tmds_init()
655 WR4(sc, HDMI_NV_PDISP_SOR_PAD_CTLS0, tmds->pad_ctls); in tmds_init()
680 for (i = 1000; i > 0; i--) { in hdmi_sor_start()
687 device_printf(sc->dev, "Timeouted while enabling SOR power.\n"); in hdmi_sor_start()
695 if (mode->flags & DRM_MODE_FLAG_NHSYNC) in hdmi_sor_start()
697 if (mode->flags & DRM_MODE_FLAG_NVSYNC) in hdmi_sor_start()
720 device_t dc; in hdmi_disable() local
723 dc = NULL; in hdmi_disable()
724 if (sc->output.encoder.crtc != NULL) { in hdmi_disable()
725 crtc = container_of(sc->output.encoder.crtc, struct tegra_crtc, in hdmi_disable()
727 dc = crtc->dev; in hdmi_disable()
730 if (dc != NULL) { in hdmi_disable()
731 TEGRA_DC_HDMI_ENABLE(dc, false); in hdmi_disable()
732 TEGRA_DC_DISPLAY_ENABLE(dc, false); in hdmi_disable()
739 /* Disable interrupts */ in hdmi_disable()
754 device_t dc; in hdmi_enable() local
757 mode = &sc->output.encoder.crtc->mode; in hdmi_enable()
758 crtc = container_of(sc->output.encoder.crtc, struct tegra_crtc, in hdmi_enable()
760 dc = crtc->dev; in hdmi_enable()
763 sc->pclk = mode->clock * 1000; in hdmi_enable()
764 h_sync_width = mode->hsync_end - mode->hsync_start; in hdmi_enable()
765 h_back_porch = mode->htotal - mode->hsync_end; in hdmi_enable()
766 h_front_porch = mode->hsync_start - mode->hdisplay; in hdmi_enable()
767 h_pulse_start = 1 + h_sync_width + h_back_porch - 10; in hdmi_enable()
768 h_max_ac_packet = (h_sync_width + h_back_porch + h_front_porch - in hdmi_enable()
769 HDMI_REKEY_DEFAULT - 18) / 32; in hdmi_enable()
772 if (sc->output.connector.edid_blob_ptr == NULL) { in hdmi_enable()
773 sc->hdmi_mode = false; in hdmi_enable()
775 sc->hdmi_mode = drm_detect_hdmi_monitor( in hdmi_enable()
776 (struct edid *)sc->output.connector.edid_blob_ptr->data); in hdmi_enable()
780 rv = clk_get_freq(sc->clk_hdmi, &freq); in hdmi_enable()
782 device_printf(sc->dev, in hdmi_enable()
799 TEGRA_DC_SETUP_TIMING(dc, h_pulse_start); in hdmi_enable()
806 if (crtc->nvidia_head != 0) in hdmi_enable()
808 if ((mode->hdisplay != 640) || (mode->vdisplay != 480)) in hdmi_enable()
812 /* Program SOR reference clock - it uses 8.2 fractional divisor */ in hdmi_enable()
818 if (sc->hdmi_mode) { in hdmi_enable()
821 sc->hdmi_mode = false; in hdmi_enable()
828 if (sc->hdmi_mode) in hdmi_enable()
833 for (i = 0; i < sc->n_tmds_configs; i++) { in hdmi_enable()
834 if (sc->pclk <= sc->tmds_config[i].pclk) { in hdmi_enable()
835 tmds_init(sc, sc->tmds_config + i); in hdmi_enable()
861 TEGRA_DC_DISPLAY_ENABLE(dc, false); in hdmi_enable()
867 TEGRA_DC_HDMI_ENABLE(dc, true); in hdmi_enable()
868 TEGRA_DC_DISPLAY_ENABLE(dc, true); in hdmi_enable()
874 if (sc->hdmi_mode) { in hdmi_enable()
882 /* -------------------------------------------------------------------
898 sc = device_get_softc(output->dev); in hdmi_connector_mode_valid()
900 freq = HDMI_DC_CLOCK_MULTIPIER * mode->clock * 1000; in hdmi_connector_mode_valid()
901 rv = clk_test_freq(sc->clk_parent, freq, 0); in hdmi_connector_mode_valid()
902 DRM_DEBUG_KMS("Test HDMI frequency: %u kHz, rv: %d\n", mode->clock, rv); in hdmi_connector_mode_valid()
965 sc = device_get_softc(output->dev); in hdmi_encoder_mode_set()
968 device_printf(sc->dev, "Cannot enable HDMI port\n"); in hdmi_encoder_mode_set()
980 sc = device_get_softc(output->dev); in hdmi_encoder_disable()
985 device_printf(sc->dev, "Cannot disable HDMI port\n"); in hdmi_encoder_disable()
994 .disable = hdmi_encoder_disable,
997 /* -------------------------------------------------------------------
1010 node = ofw_bus_get_node(sc->dev); in hdmi_init_client()
1011 sc->drm = drm; in hdmi_init_client()
1012 sc->output.setup_clock = &hdmi_setup_clock; in hdmi_init_client()
1014 rv = tegra_drm_encoder_attach(&sc->output, node); in hdmi_init_client()
1021 drm_connector_init(&drm->drm_dev, &sc->output.connector, in hdmi_init_client()
1024 drm_connector_helper_add(&sc->output.connector, in hdmi_init_client()
1027 sc->output.connector.dpms = DRM_MODE_DPMS_OFF; in hdmi_init_client()
1029 drm_encoder_init(&drm->drm_dev, &sc->output.encoder, in hdmi_init_client()
1032 drm_encoder_helper_add(&sc->output.encoder, &hdmi_encoder_helper_funcs); in hdmi_init_client()
1034 drm_mode_connector_attach_encoder(&sc->output.connector, in hdmi_init_client()
1035 &sc->output.encoder); in hdmi_init_client()
1037 rv = tegra_drm_encoder_init(&sc->output, drm); in hdmi_init_client()
1039 device_printf(sc->dev, "Unable to init HDMI output\n"); in hdmi_init_client()
1042 sc->output.encoder.possible_crtcs = 0x3; in hdmi_init_client()
1052 tegra_drm_encoder_exit(&sc->output, drm); in hdmi_exit_client()
1061 rv = regulator_get_by_ofw_property(sc->dev, 0, "hdmi-supply", in get_fdt_resources()
1062 &sc->supply_hdmi); in get_fdt_resources()
1064 device_printf(sc->dev, "Cannot get 'hdmi' regulator\n"); in get_fdt_resources()
1067 rv = regulator_get_by_ofw_property(sc->dev,0, "pll-supply", in get_fdt_resources()
1068 &sc->supply_pll); in get_fdt_resources()
1070 device_printf(sc->dev, "Cannot get 'pll' regulator\n"); in get_fdt_resources()
1073 rv = regulator_get_by_ofw_property(sc->dev, 0, "vdd-supply", in get_fdt_resources()
1074 &sc->supply_vdd); in get_fdt_resources()
1076 device_printf(sc->dev, "Cannot get 'vdd' regulator\n"); in get_fdt_resources()
1080 rv = hwreset_get_by_ofw_name(sc->dev, 0, "hdmi", &sc->hwreset_hdmi); in get_fdt_resources()
1082 device_printf(sc->dev, "Cannot get 'hdmi' reset\n"); in get_fdt_resources()
1085 rv = clk_get_by_ofw_name(sc->dev, 0, "parent", &sc->clk_parent); in get_fdt_resources()
1087 device_printf(sc->dev, "Cannot get 'parent' clock\n"); in get_fdt_resources()
1090 rv = clk_get_by_ofw_name(sc->dev, 0, "hdmi", &sc->clk_hdmi); in get_fdt_resources()
1092 device_printf(sc->dev, "Cannot get 'hdmi' clock\n"); in get_fdt_resources()
1104 rv = clk_set_parent_by_clk(sc->clk_hdmi, sc->clk_parent); in enable_fdt_resources()
1106 device_printf(sc->dev, in enable_fdt_resources()
1112 rv = clk_set_freq(sc->clk_parent, 594000000, 0); in enable_fdt_resources()
1114 device_printf(sc->dev, in enable_fdt_resources()
1118 rv = clk_set_freq(sc->clk_hdmi, 594000000 / 4, 0); in enable_fdt_resources()
1120 device_printf(sc->dev, in enable_fdt_resources()
1125 rv = regulator_enable(sc->supply_hdmi); in enable_fdt_resources()
1127 device_printf(sc->dev, "Cannot enable 'hdmi' regulator\n"); in enable_fdt_resources()
1130 rv = regulator_enable(sc->supply_pll); in enable_fdt_resources()
1132 device_printf(sc->dev, "Cannot enable 'pll' regulator\n"); in enable_fdt_resources()
1135 rv = regulator_enable(sc->supply_vdd); in enable_fdt_resources()
1137 device_printf(sc->dev, "Cannot enable 'vdd' regulator\n"); in enable_fdt_resources()
1141 rv = clk_enable(sc->clk_hdmi); in enable_fdt_resources()
1143 device_printf(sc->dev, "Cannot enable 'hdmi' clock\n"); in enable_fdt_resources()
1147 rv = hwreset_deassert(sc->hwreset_hdmi); in enable_fdt_resources()
1149 device_printf(sc->dev, "Cannot unreset 'hdmi' reset\n"); in enable_fdt_resources()
1179 if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) in hdmi_probe()
1194 sc->dev = dev; in hdmi_attach()
1195 sc->output.dev = sc->dev; in hdmi_attach()
1196 node = ofw_bus_get_node(sc->dev); in hdmi_attach()
1198 sc->audio_src_type = SOURCE_SELECT_AUTO; in hdmi_attach()
1199 sc->audio_freq = 44100; in hdmi_attach()
1200 sc->audio_chans = 2; in hdmi_attach()
1201 sc->hdmi_mode = false; in hdmi_attach()
1203 sc->tmds_config = tegra124_tmds_config; in hdmi_attach()
1204 sc->n_tmds_configs = nitems(tegra124_tmds_config); in hdmi_attach()
1207 sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, in hdmi_attach()
1209 if (sc->mem_res == NULL) { in hdmi_attach()
1215 sc->irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE); in hdmi_attach()
1216 if (sc->irq_res == NULL) { in hdmi_attach()
1221 rv = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_MISC | INTR_MPSAFE, in hdmi_attach()
1222 NULL, hdmi_intr, sc, &sc->irq_ih); in hdmi_attach()
1240 rv = TEGRA_DRM_REGISTER_CLIENT(device_get_parent(sc->dev), sc->dev); in hdmi_attach()
1248 TEGRA_DRM_DEREGISTER_CLIENT(device_get_parent(sc->dev), sc->dev); in hdmi_attach()
1250 if (sc->irq_ih != NULL) in hdmi_attach()
1251 bus_teardown_intr(dev, sc->irq_res, sc->irq_ih); in hdmi_attach()
1252 if (sc->clk_parent != NULL) in hdmi_attach()
1253 clk_release(sc->clk_parent); in hdmi_attach()
1254 if (sc->clk_hdmi != NULL) in hdmi_attach()
1255 clk_release(sc->clk_hdmi); in hdmi_attach()
1256 if (sc->hwreset_hdmi != NULL) in hdmi_attach()
1257 hwreset_release(sc->hwreset_hdmi); in hdmi_attach()
1258 if (sc->supply_hdmi != NULL) in hdmi_attach()
1259 regulator_release(sc->supply_hdmi); in hdmi_attach()
1260 if (sc->supply_pll != NULL) in hdmi_attach()
1261 regulator_release(sc->supply_pll); in hdmi_attach()
1262 if (sc->supply_vdd != NULL) in hdmi_attach()
1263 regulator_release(sc->supply_vdd); in hdmi_attach()
1264 if (sc->irq_res != NULL) in hdmi_attach()
1265 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq_res); in hdmi_attach()
1266 if (sc->mem_res != NULL) in hdmi_attach()
1267 bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->mem_res); in hdmi_attach()
1283 TEGRA_DRM_DEREGISTER_CLIENT(device_get_parent(sc->dev), sc->dev); in hdmi_detach()
1285 if (sc->irq_ih != NULL) in hdmi_detach()
1286 bus_teardown_intr(dev, sc->irq_res, sc->irq_ih); in hdmi_detach()
1287 if (sc->clk_parent != NULL) in hdmi_detach()
1288 clk_release(sc->clk_parent); in hdmi_detach()
1289 if (sc->clk_hdmi != NULL) in hdmi_detach()
1290 clk_release(sc->clk_hdmi); in hdmi_detach()
1291 if (sc->hwreset_hdmi != NULL) in hdmi_detach()
1292 hwreset_release(sc->hwreset_hdmi); in hdmi_detach()
1293 if (sc->supply_hdmi != NULL) in hdmi_detach()
1294 regulator_release(sc->supply_hdmi); in hdmi_detach()
1295 if (sc->supply_pll != NULL) in hdmi_detach()
1296 regulator_release(sc->supply_pll); in hdmi_detach()
1297 if (sc->supply_vdd != NULL) in hdmi_detach()
1298 regulator_release(sc->supply_vdd); in hdmi_detach()
1299 if (sc->irq_res != NULL) in hdmi_detach()
1300 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq_res); in hdmi_detach()
1301 if (sc->mem_res != NULL) in hdmi_detach()
1302 bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->mem_res); in hdmi_detach()