Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/arm/allwinner Turn off video output on WSDISPLAYIO_...
details: https://anonhg.NetBSD.org/src/rev/c480ada0866f
branches: trunk
changeset: 341715:c480ada0866f
user: bouyer <bouyer%NetBSD.org@localhost>
date: Thu Nov 19 18:48:22 2015 +0000
description:
Turn off video output on WSDISPLAYIO_SVIDEO.
For LCD/LVDS, just stop the tcon0.
For HDMI, turn off tcon and hdmi (so that the monitor goes to sleeo)
if the audio output is inactive.
For this, add a lock-protected refcount in awin_hdmi, incremented when
audio and/or video is active.
Tested with an audio-enabled HDMI display.
diffstat:
sys/arch/arm/allwinner/awin_debe.c | 14 +++++++-
sys/arch/arm/allwinner/awin_hdmi.c | 40 ++++++++++++++++++++++++-
sys/arch/arm/allwinner/awin_hdmiaudio.c | 6 ++-
sys/arch/arm/allwinner/awin_tcon.c | 51 +++++++++++++++++++++++++++++++-
sys/arch/arm/allwinner/awin_var.h | 4 +-
5 files changed, 106 insertions(+), 9 deletions(-)
diffs (263 lines):
diff -r 8028bda1a30a -r c480ada0866f sys/arch/arm/allwinner/awin_debe.c
--- a/sys/arch/arm/allwinner/awin_debe.c Thu Nov 19 17:04:01 2015 +0000
+++ b/sys/arch/arm/allwinner/awin_debe.c Thu Nov 19 18:48:22 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_debe.c,v 1.18 2015/11/03 18:38:03 bouyer Exp $ */
+/* $NetBSD: awin_debe.c,v 1.19 2015/11/19 18:48:22 bouyer Exp $ */
/*-
* Copyright (c) 2014 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -37,7 +37,7 @@
#define AWIN_DEBE_CURMAX 64
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: awin_debe.c,v 1.18 2015/11/03 18:38:03 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: awin_debe.c,v 1.19 2015/11/19 18:48:22 bouyer Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -583,6 +583,10 @@
enable = *(int *)data;
val = DEBE_READ(sc, AWIN_DEBE_MODCTL_REG);
if (enable) {
+ if (val & AWIN_DEBE_MODCTL_LAY0_EN) {
+ /* already enabled */
+ return 0;
+ }
val |= AWIN_DEBE_MODCTL_LAY0_EN;
if (sc->sc_cursor_enable) {
val |= AWIN_DEBE_MODCTL_HWC_EN;
@@ -590,10 +594,16 @@
val &= ~AWIN_DEBE_MODCTL_HWC_EN;
}
} else {
+ if ((val & AWIN_DEBE_MODCTL_LAY0_EN) == 0) {
+ /* already disabled */
+ return 0;
+ }
val &= ~AWIN_DEBE_MODCTL_LAY0_EN;
val &= ~AWIN_DEBE_MODCTL_HWC_EN;
}
DEBE_WRITE(sc, AWIN_DEBE_MODCTL_REG, val);
+ /* debe0 always connected to tcon0, debe1 to tcon1*/
+ awin_tcon_setvideo(device_unit(sc->sc_dev), enable);
return 0;
case WSDISPLAYIO_GVIDEO:
val = DEBE_READ(sc, AWIN_DEBE_MODCTL_REG);
diff -r 8028bda1a30a -r c480ada0866f sys/arch/arm/allwinner/awin_hdmi.c
--- a/sys/arch/arm/allwinner/awin_hdmi.c Thu Nov 19 17:04:01 2015 +0000
+++ b/sys/arch/arm/allwinner/awin_hdmi.c Thu Nov 19 18:48:22 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_hdmi.c,v 1.18 2015/11/15 21:28:54 bouyer Exp $ */
+/* $NetBSD: awin_hdmi.c,v 1.19 2015/11/19 18:48:22 bouyer Exp $ */
/*-
* Copyright (c) 2014 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -30,7 +30,7 @@
#include "opt_ddb.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: awin_hdmi.c,v 1.18 2015/11/15 21:28:54 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: awin_hdmi.c,v 1.19 2015/11/19 18:48:22 bouyer Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -74,6 +74,9 @@
int sc_tcon_unit;
unsigned int sc_tcon_pll;
+ kmutex_t sc_pwr_lock;
+ int sc_pwr_refcount; /* reference who needs HDMI */
+
uint32_t sc_ver;
unsigned int sc_i2c_blklen;
};
@@ -219,6 +222,9 @@
aprint_normal_dev(self, "interrupting on irq %d\n", loc->loc_intr);
#endif
+ mutex_init(&sc->sc_pwr_lock, MUTEX_DEFAULT, IPL_NONE);
+ sc->sc_pwr_refcount = 1; /* we start with video powered on */
+
awin_hdmi_i2c_init(sc);
awin_hdmi_enable(sc);
@@ -990,6 +996,36 @@
}
}
+void
+awin_hdmi_poweron(bool enable)
+{
+ struct awin_hdmi_softc *sc;
+ device_t dev;
+
+ dev = device_find_by_driver_unit("awinhdmi", 0);
+ if (dev == NULL) {
+ return;
+ }
+ sc = device_private(dev);
+ mutex_enter(&sc->sc_pwr_lock);
+ if (enable) {
+ KASSERT(sc->sc_pwr_refcount >= 0);
+ if (sc->sc_pwr_refcount == 0) {
+ awin_tcon1_enable(sc->sc_tcon_unit, true);
+ awin_hdmi_video_enable(sc, true);
+ }
+ sc->sc_pwr_refcount++;
+ } else {
+ sc->sc_pwr_refcount--;
+ KASSERT(sc->sc_pwr_refcount >= 0);
+ if (sc->sc_pwr_refcount == 0) {
+ awin_hdmi_video_enable(sc, false);
+ awin_tcon1_enable(sc->sc_tcon_unit, false);
+ }
+ }
+ mutex_exit(&sc->sc_pwr_lock);
+}
+
#if defined(DDB)
void
awin_hdmi_dump_regs(void)
diff -r 8028bda1a30a -r c480ada0866f sys/arch/arm/allwinner/awin_hdmiaudio.c
--- a/sys/arch/arm/allwinner/awin_hdmiaudio.c Thu Nov 19 17:04:01 2015 +0000
+++ b/sys/arch/arm/allwinner/awin_hdmiaudio.c Thu Nov 19 18:48:22 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_hdmiaudio.c,v 1.5 2014/11/18 01:53:53 jmcneill Exp $ */
+/* $NetBSD: awin_hdmiaudio.c,v 1.6 2015/11/19 18:48:22 bouyer Exp $ */
/*-
* Copyright (c) 2014 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: awin_hdmiaudio.c,v 1.5 2014/11/18 01:53:53 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: awin_hdmiaudio.c,v 1.6 2015/11/19 18:48:22 bouyer Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -410,6 +410,7 @@
sc->sc_pint = NULL;
sc->sc_pintarg = NULL;
+ awin_hdmi_poweron(false);
return 0;
}
@@ -638,6 +639,7 @@
sc->sc_pstart = sc->sc_pcur = pstart;
sc->sc_pend = sc->sc_pstart + psize;
sc->sc_pblksize = blksize;
+ awin_hdmi_poweron(true);
dmacfg = 0;
dmacfg |= __SHIFTIN(AWIN_DMA_CTL_DATA_WIDTH_32,
diff -r 8028bda1a30a -r c480ada0866f sys/arch/arm/allwinner/awin_tcon.c
--- a/sys/arch/arm/allwinner/awin_tcon.c Thu Nov 19 17:04:01 2015 +0000
+++ b/sys/arch/arm/allwinner/awin_tcon.c Thu Nov 19 18:48:22 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_tcon.c,v 1.9 2015/11/15 21:28:54 bouyer Exp $ */
+/* $NetBSD: awin_tcon.c,v 1.10 2015/11/19 18:48:22 bouyer Exp $ */
/*-
* Copyright (c) 2014 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -29,7 +29,7 @@
#include "opt_allwinner.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: awin_tcon.c,v 1.9 2015/11/15 21:28:54 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: awin_tcon.c,v 1.10 2015/11/19 18:48:22 bouyer Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -91,6 +91,7 @@
static void awin_tcon_set_pll(struct awin_tcon_softc *, int, int);
static void awin_tcon0_set_video(struct awin_tcon_softc *);
+static void awin_tcon0_enable(struct awin_tcon_softc *, bool);
static void
awin_tcon_clear_reset(struct awinio_attach_args * const aio, int unit)
@@ -537,6 +538,32 @@
}
}
+static void
+awin_tcon0_enable(struct awin_tcon_softc *sc, bool enable) {
+ uint32_t val;
+
+ /* turn on/off backlight */
+ if (sc->sc_lcdblk_pin_name != NULL) {
+ awin_gpio_pindata_write(&sc->sc_lcdblk_pin, enable ? 1 : 0);
+ }
+ /* turn on/off LCD */
+ if (sc->sc_lcdpwr_pin_name != NULL) {
+ awin_gpio_pindata_write(&sc->sc_lcdpwr_pin, enable ? 1 : 0);
+ }
+ /* and finally disable of enable the tcon */
+ KASSERT(sc->sc_output_type != OUTPUT_HDMI);
+
+ awin_debe_enable(device_unit(sc->sc_dev), enable);
+ delay(20000);
+ val = TCON_READ(sc, AWIN_TCON_GCTL_REG);
+ if (enable) {
+ val |= AWIN_TCON_GCTL_EN;
+ } else {
+ val &= ~AWIN_TCON_GCTL_EN;
+ }
+ TCON_WRITE(sc, AWIN_TCON_GCTL_REG, val);
+}
+
void
awin_tcon1_enable(int unit, bool enable)
{
@@ -736,3 +763,23 @@
return sc->sc_clk_dbl;
}
+
+void
+awin_tcon_setvideo(int unit, bool enable)
+{
+ struct awin_tcon_softc *sc;
+ device_t dev;
+
+ dev = device_find_by_driver_unit("awintcon", unit);
+ if (dev == NULL) {
+ printf("TCON%d: no driver found\n", unit);
+ return;
+ }
+ sc = device_private(dev);
+
+ if (sc->sc_output_type == OUTPUT_HDMI) {
+ awin_hdmi_poweron(enable);
+ } else {
+ awin_tcon0_enable(sc, enable);
+ }
+}
diff -r 8028bda1a30a -r c480ada0866f sys/arch/arm/allwinner/awin_var.h
--- a/sys/arch/arm/allwinner/awin_var.h Thu Nov 19 17:04:01 2015 +0000
+++ b/sys/arch/arm/allwinner/awin_var.h Thu Nov 19 18:48:22 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_var.h,v 1.38 2015/11/15 21:28:54 bouyer Exp $ */
+/* $NetBSD: awin_var.h,v 1.39 2015/11/19 18:48:22 bouyer Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -142,6 +142,7 @@
bool awin_tcon_get_clk_dbl(int);
void awin_tcon1_set_videomode(int, const struct videomode *);
void awin_tcon1_enable(int, bool);
+void awin_tcon_setvideo(int, bool);
void awin_debe_set_videomode(int, const struct videomode *);
void awin_debe_enable(int, bool);
int awin_debe_ioctl(device_t, u_long, void *);
@@ -155,6 +156,7 @@
bool display_hdmimode;
};
void awin_hdmi_get_info(struct awin_hdmi_info *);
+void awin_hdmi_poweron(bool);
void awin_fb_set_videomode(device_t, u_int, u_int);
void awin_fb_ddb_trap_callback(int);
Home |
Main Index |
Thread Index |
Old Index