Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/terasic/mtl/terasic_mtl.c
Show All 25 Lines | |||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
* SUCH DAMAGE. | * SUCH DAMAGE. | ||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include "opt_syscons.h" | |||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/bus.h> | #include <sys/bus.h> | ||||
#include <sys/condvar.h> | #include <sys/condvar.h> | ||||
#include <sys/conf.h> | #include <sys/conf.h> | ||||
#include <sys/consio.h> /* struct vt_mode */ | #include <sys/consio.h> /* struct vt_mode */ | ||||
#include <sys/fbio.h> /* video_adapter_t */ | #include <sys/fbio.h> /* video_adapter_t */ | ||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/lock.h> | #include <sys/lock.h> | ||||
#include <sys/malloc.h> | #include <sys/malloc.h> | ||||
#include <sys/module.h> | #include <sys/module.h> | ||||
#include <sys/mutex.h> | #include <sys/mutex.h> | ||||
#include <sys/rman.h> | #include <sys/rman.h> | ||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
#include <machine/bus.h> | #include <machine/bus.h> | ||||
#include <machine/resource.h> | #include <machine/resource.h> | ||||
#include <dev/terasic/mtl/terasic_mtl.h> | #include <dev/terasic/mtl/terasic_mtl.h> | ||||
/* | /* | ||||
* Device driver for the Terasic Multitouch LCD (MTL). Three separate | * Device driver for the Terasic Multitouch LCD (MTL). Three separate | ||||
* sub-drivers that support, respectively, access to device control registers, | * sub-drivers that support, respectively, access to device control registers, | ||||
* the pixel frame buffer, and the text frame buffer. The last of these is | * the pixel frame buffer, and the text frame buffer. The pixel frame buffer | ||||
* also hooked up to syscons. | * is hooked up to vt(4), and the text frame buffer to syscons(4). | ||||
* | * | ||||
* Eventually, the frame buffer control registers and touch screen input FIFO | * Eventually, the frame buffer control registers and touch screen input FIFO | ||||
* will end up being separate sub-drivers as well. | * will end up being separate sub-drivers as well. | ||||
* | * | ||||
* Note: sub-driver detach routines must check whether or not they have | * Note: sub-driver detach routines must check whether or not they have | ||||
* attached as they may be called even if the attach routine hasn't been, on | * attached as they may be called even if the attach routine hasn't been, on | ||||
* an error. | * an error. | ||||
*/ | */ | ||||
Show All 10 Lines | if (error) | ||||
goto error; | goto error; | ||||
error = terasic_mtl_pixel_attach(sc); | error = terasic_mtl_pixel_attach(sc); | ||||
if (error) | if (error) | ||||
goto error; | goto error; | ||||
error = terasic_mtl_text_attach(sc); | error = terasic_mtl_text_attach(sc); | ||||
if (error) | if (error) | ||||
goto error; | goto error; | ||||
/* | /* | ||||
* XXXRW: Once we've attached syscons, we can't detach it, so do it | * XXXRW: Once we've attached syscons or vt, we can't detach it, so do | ||||
* last. | * it last. | ||||
*/ | */ | ||||
#if defined(DEV_VT) | |||||
error = terasic_mtl_fbd_attach(sc); | |||||
if (error) | |||||
goto error; | |||||
terasic_mtl_blend_pixel_set(sc, TERASIC_MTL_ALPHA_OPAQUE); | |||||
terasic_mtl_blend_textfg_set(sc, TERASIC_MTL_ALPHA_TRANSPARENT); | |||||
terasic_mtl_blend_textbg_set(sc, TERASIC_MTL_ALPHA_TRANSPARENT); | |||||
#endif | |||||
#if defined(DEV_SC) | |||||
error = terasic_mtl_syscons_attach(sc); | error = terasic_mtl_syscons_attach(sc); | ||||
if (error) | if (error) | ||||
goto error; | goto error; | ||||
terasic_mtl_blend_default_set(sc, TERASIC_MTL_COLOR_BLACK); | |||||
terasic_mtl_blend_pixel_set(sc, TERASIC_MTL_ALPHA_TRANSPARENT); | terasic_mtl_blend_pixel_set(sc, TERASIC_MTL_ALPHA_TRANSPARENT); | ||||
terasic_mtl_blend_textfg_set(sc, TERASIC_MTL_ALPHA_OPAQUE); | terasic_mtl_blend_textfg_set(sc, TERASIC_MTL_ALPHA_OPAQUE); | ||||
terasic_mtl_blend_textbg_set(sc, TERASIC_MTL_ALPHA_OPAQUE); | terasic_mtl_blend_textbg_set(sc, TERASIC_MTL_ALPHA_OPAQUE); | ||||
#endif | |||||
terasic_mtl_blend_default_set(sc, TERASIC_MTL_COLOR_BLACK); | |||||
return (0); | return (0); | ||||
error: | error: | ||||
terasic_mtl_text_detach(sc); | terasic_mtl_text_detach(sc); | ||||
terasic_mtl_pixel_detach(sc); | terasic_mtl_pixel_detach(sc); | ||||
terasic_mtl_reg_detach(sc); | terasic_mtl_reg_detach(sc); | ||||
return (error); | return (error); | ||||
} | } | ||||
void | void | ||||
terasic_mtl_detach(struct terasic_mtl_softc *sc) | terasic_mtl_detach(struct terasic_mtl_softc *sc) | ||||
{ | { | ||||
/* XXXRW: syscons can't detach, but we try anyway, only to panic. */ | /* XXXRW: syscons and vt can't detach, but try anyway, only to panic. */ | ||||
#if defined(DEV_SC) | |||||
terasic_mtl_syscons_detach(sc); | terasic_mtl_syscons_detach(sc); | ||||
#endif | |||||
#if defined(DEV_VT) | |||||
terasic_mtl_fbd_detach(sc); | |||||
#endif | |||||
/* All other aspects of the driver can detach just fine. */ | /* All other aspects of the driver can detach just fine. */ | ||||
terasic_mtl_text_detach(sc); | terasic_mtl_text_detach(sc); | ||||
terasic_mtl_pixel_detach(sc); | terasic_mtl_pixel_detach(sc); | ||||
terasic_mtl_reg_detach(sc); | terasic_mtl_reg_detach(sc); | ||||
} | } |