Changeset View
Changeset View
Standalone View
Standalone View
sys/compat/linuxkpi/common/src/linux_pci.c
Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | |||||
#include <vm/vm.h> | #include <vm/vm.h> | ||||
#include <vm/pmap.h> | #include <vm/pmap.h> | ||||
#include <machine/stdarg.h> | #include <machine/stdarg.h> | ||||
#include <dev/pci/pcivar.h> | #include <dev/pci/pcivar.h> | ||||
#include <dev/pci/pci_private.h> | #include <dev/pci/pci_private.h> | ||||
#include <dev/pci/pci_iov.h> | #include <dev/pci/pci_iov.h> | ||||
#include <dev/backlight/backlight.h> | |||||
#include <linux/kobject.h> | #include <linux/kobject.h> | ||||
#include <linux/device.h> | #include <linux/device.h> | ||||
#include <linux/slab.h> | #include <linux/slab.h> | ||||
#include <linux/module.h> | #include <linux/module.h> | ||||
#include <linux/cdev.h> | #include <linux/cdev.h> | ||||
#include <linux/file.h> | #include <linux/file.h> | ||||
#include <linux/sysfs.h> | #include <linux/sysfs.h> | ||||
#include <linux/mm.h> | #include <linux/mm.h> | ||||
#include <linux/io.h> | #include <linux/io.h> | ||||
#include <linux/vmalloc.h> | #include <linux/vmalloc.h> | ||||
#include <linux/pci.h> | #include <linux/pci.h> | ||||
#include <linux/compat.h> | #include <linux/compat.h> | ||||
#include <linux/backlight.h> | |||||
#include "backlight_if.h" | |||||
static device_probe_t linux_pci_probe; | static device_probe_t linux_pci_probe; | ||||
static device_attach_t linux_pci_attach; | static device_attach_t linux_pci_attach; | ||||
static device_detach_t linux_pci_detach; | static device_detach_t linux_pci_detach; | ||||
static device_suspend_t linux_pci_suspend; | static device_suspend_t linux_pci_suspend; | ||||
static device_resume_t linux_pci_resume; | static device_resume_t linux_pci_resume; | ||||
static device_shutdown_t linux_pci_shutdown; | static device_shutdown_t linux_pci_shutdown; | ||||
static pci_iov_init_t linux_pci_iov_init; | static pci_iov_init_t linux_pci_iov_init; | ||||
static pci_iov_uninit_t linux_pci_iov_uninit; | static pci_iov_uninit_t linux_pci_iov_uninit; | ||||
static pci_iov_add_vf_t linux_pci_iov_add_vf; | static pci_iov_add_vf_t linux_pci_iov_add_vf; | ||||
static int linux_backlight_get_status(device_t dev, struct backlight_props *props); | |||||
static int linux_backlight_update_status(device_t dev, struct backlight_props *props); | |||||
static device_method_t pci_methods[] = { | static device_method_t pci_methods[] = { | ||||
DEVMETHOD(device_probe, linux_pci_probe), | DEVMETHOD(device_probe, linux_pci_probe), | ||||
DEVMETHOD(device_attach, linux_pci_attach), | DEVMETHOD(device_attach, linux_pci_attach), | ||||
DEVMETHOD(device_detach, linux_pci_detach), | DEVMETHOD(device_detach, linux_pci_detach), | ||||
DEVMETHOD(device_suspend, linux_pci_suspend), | DEVMETHOD(device_suspend, linux_pci_suspend), | ||||
DEVMETHOD(device_resume, linux_pci_resume), | DEVMETHOD(device_resume, linux_pci_resume), | ||||
DEVMETHOD(device_shutdown, linux_pci_shutdown), | DEVMETHOD(device_shutdown, linux_pci_shutdown), | ||||
DEVMETHOD(pci_iov_init, linux_pci_iov_init), | DEVMETHOD(pci_iov_init, linux_pci_iov_init), | ||||
DEVMETHOD(pci_iov_uninit, linux_pci_iov_uninit), | DEVMETHOD(pci_iov_uninit, linux_pci_iov_uninit), | ||||
DEVMETHOD(pci_iov_add_vf, linux_pci_iov_add_vf), | DEVMETHOD(pci_iov_add_vf, linux_pci_iov_add_vf), | ||||
/* backlight interface */ | |||||
DEVMETHOD(backlight_update_status, linux_backlight_update_status), | |||||
DEVMETHOD(backlight_get_status, linux_backlight_get_status), | |||||
DEVMETHOD_END | DEVMETHOD_END | ||||
}; | }; | ||||
struct linux_dma_priv { | struct linux_dma_priv { | ||||
uint64_t dma_mask; | uint64_t dma_mask; | ||||
struct mtx lock; | struct mtx lock; | ||||
bus_dma_tag_t dmat; | bus_dma_tag_t dmat; | ||||
struct pctrie ptree; | struct pctrie ptree; | ||||
▲ Show 20 Lines • Show All 851 Lines • ▼ Show 20 Lines | linux_dma_pool_free(struct dma_pool *pool, void *vaddr, dma_addr_t dma_addr) | ||||
if (obj == NULL) { | if (obj == NULL) { | ||||
DMA_POOL_UNLOCK(pool); | DMA_POOL_UNLOCK(pool); | ||||
return; | return; | ||||
} | } | ||||
LINUX_DMA_PCTRIE_REMOVE(&pool->pool_ptree, dma_addr); | LINUX_DMA_PCTRIE_REMOVE(&pool->pool_ptree, dma_addr); | ||||
DMA_POOL_UNLOCK(pool); | DMA_POOL_UNLOCK(pool); | ||||
uma_zfree_arg(pool->pool_zone, obj, pool); | uma_zfree_arg(pool->pool_zone, obj, pool); | ||||
} | |||||
static int | |||||
linux_backlight_get_status(device_t dev, struct backlight_props *props) | |||||
{ | |||||
struct pci_dev *pdev; | |||||
linux_set_current(curthread); | |||||
pdev = device_get_softc(dev); | |||||
props->brightness = pdev->dev.bd->props.brightness; | |||||
props->brightness = props->brightness * 100 / pdev->dev.bd->props.max_brightness; | |||||
props->nlevels = 0; | |||||
return (0); | |||||
} | |||||
static int | |||||
linux_backlight_update_status(device_t dev, struct backlight_props *props) | |||||
{ | |||||
struct pci_dev *pdev; | |||||
linux_set_current(curthread); | |||||
pdev = device_get_softc(dev); | |||||
pdev->dev.bd->props.brightness = pdev->dev.bd->props.max_brightness * | |||||
props->brightness / 100; | |||||
return (pdev->dev.bd->ops->update_status(pdev->dev.bd)); | |||||
} | |||||
struct backlight_device * | |||||
linux_backlight_device_register(const char *name, struct device *dev, | |||||
void *data, const struct backlight_ops *ops, struct backlight_properties *props) | |||||
{ | |||||
dev->bd = malloc(sizeof(*dev->bd), M_DEVBUF, M_WAITOK | M_ZERO); | |||||
dev->bd->ops = ops; | |||||
dev->bd->props.type = props->type; | |||||
dev->bd->props.max_brightness = props->max_brightness; | |||||
dev->bd->props.brightness = props->brightness; | |||||
dev->bd->props.power = props->power; | |||||
dev->bd->data = data; | |||||
dev->bd->dev = dev; | |||||
dev->backlight_dev = backlight_register(name, dev->bsddev); | |||||
return (dev->bd); | |||||
} | |||||
void | |||||
linux_backlight_device_unregister(struct backlight_device *bd) | |||||
{ | |||||
backlight_destroy(bd->dev->backlight_dev); | |||||
} | } |