add ddc_dev_read_edid{,_block} functions, same as ddc_read_edid{,_block} but takes a device_t instead of i2c_tag_t
This commit is contained in:
parent
0c927cbd69
commit
741d9fcdd4
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ddc.c,v 1.4 2014/11/17 00:46:44 jmcneill Exp $ */
|
||||
/* $NetBSD: ddc.c,v 1.5 2015/05/17 01:27:16 jmcneill Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2006 Itronix Inc.
|
||||
@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ddc.c,v 1.4 2014/11/17 00:46:44 jmcneill Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ddc.c,v 1.5 2015/05/17 01:27:16 jmcneill Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -80,6 +80,7 @@ ddc_attach(device_t parent, device_t self, void *aux)
|
||||
struct ddc_softc *sc = device_private(self);
|
||||
struct i2c_attach_args *ia = aux;
|
||||
|
||||
sc->sc_tag = ia->ia_tag;
|
||||
sc->sc_address = ia->ia_addr;
|
||||
|
||||
aprint_naive(": DDC\n");
|
||||
@ -98,17 +99,34 @@ int
|
||||
ddc_read_edid_block(i2c_tag_t tag, uint8_t *dest, size_t len, uint8_t block)
|
||||
{
|
||||
uint8_t wbuf[2];
|
||||
int error;
|
||||
|
||||
if (iic_acquire_bus(tag, I2C_F_POLL) != 0)
|
||||
return -1;
|
||||
if ((error = iic_acquire_bus(tag, I2C_F_POLL)) != 0)
|
||||
return error;
|
||||
|
||||
wbuf[0] = block; /* start address */
|
||||
|
||||
if (iic_exec(tag, I2C_OP_READ_WITH_STOP, DDC_ADDR, wbuf, 1, dest,
|
||||
len, I2C_F_POLL)) {
|
||||
if ((error = iic_exec(tag, I2C_OP_READ_WITH_STOP, DDC_ADDR, wbuf, 1,
|
||||
dest, len, I2C_F_POLL)) != 0) {
|
||||
iic_release_bus(tag, I2C_F_POLL);
|
||||
return -1;
|
||||
return error;
|
||||
}
|
||||
iic_release_bus(tag, I2C_F_POLL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
ddc_dev_read_edid(device_t dev, uint8_t *dest, size_t len)
|
||||
{
|
||||
return ddc_dev_read_edid_block(dev, dest, len, DDC_EDID_START);
|
||||
}
|
||||
|
||||
int
|
||||
ddc_dev_read_edid_block(device_t dev, uint8_t *dest, size_t len, uint8_t block)
|
||||
{
|
||||
if (!device_is_a(dev, "ddc"))
|
||||
return EINVAL;
|
||||
|
||||
const struct ddc_softc *sc = device_private(dev);
|
||||
return ddc_read_edid_block(sc->sc_tag, dest, len, block);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ddcvar.h,v 1.2 2014/11/17 00:46:44 jmcneill Exp $ */
|
||||
/* $NetBSD: ddcvar.h,v 1.3 2015/05/17 01:27:16 jmcneill Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2006 Itronix Inc.
|
||||
@ -35,6 +35,9 @@
|
||||
#ifndef _DEV_I2C_DDCVAR_H_
|
||||
#define _DEV_I2C_DDCVAR_H_
|
||||
|
||||
int ddc_dev_read_edid(device_t, u_int8_t *, size_t);
|
||||
int ddc_dev_read_edid_block(device_t, u_int8_t *, size_t, uint8_t);
|
||||
|
||||
/*
|
||||
* display drivers can use this to access DDC without using the
|
||||
* autoconfiguration framework.
|
||||
|
Loading…
Reference in New Issue
Block a user