Permalink
Browse files

more port

  • Loading branch information...
1 parent f8c5e5c commit b14c58e74ff90068650bb4d5ababbc614619844b @mlankhorst mlankhorst committed Apr 10, 2012
View
@@ -2,8 +2,8 @@
KMOD= pscnv
HEADERS= nouveau_bios.h nouveau_connector.h nouveau_crtc.h nouveau_dma.h nouveau_drv.h nouveau_encoder.h nouveau_fb.h nouveau_fbcon.h nouveau_grctx.h nouveau_hw.h nouveau_hwsq.h nouveau_i2c.h nouveau_pm.h nouveau_reg.h nv50_chan.h nv50_display.h nv50_evo.h nv50_vm.h nvc0_chan.h nvc0_copy.h nvc0_graph.h nvc0_pgraph.xml.h nvc0_vm.h nvreg.h pscnv_chan.h pscnv_drm.h pscnv_engine.h pscnv_fifo.h pscnv_gem.h pscnv_ioctl.h pscnv_mem.h pscnv_mm.h pscnv_ramht.h pscnv_tree.h pscnv_vm.h
-C_SRCS=nouveau_bios.c nouveau_calc.c nouveau_connector.c nouveau_display.c nouveau_dma.c nouveau_dp.c nouveau_bsddrv.c nouveau_fbcon.c nouveau_hw.c nouveau_i2c.c nouveau_irq.c nouveau_mem.c nouveau_perf.c nouveau_pm.c nouveau_state.c nouveau_temp.c nouveau_volt.c nv04_dac.c nv04_dfp.c nv04_pm.c nv04_timer.c nv04_tv.c nv10_gpio.c nv40_counter.c nv50_calc.c nv50_chan.c nv50_crtc.c nv50_cursor.c nv50_dac.c nv50_display.c nv50_fifo.c nv50_gpio.c nv50_graph.c nv50_grctx.c nv50_pm.c nv50_sor.c nv50_vm.c nv50_vram.c nv84_crypt.c nv98_crypt.c nva3_pm.c nvc0_chan.c nvc0_copy.c nvc0_fifo.c nvc0_graph.c nvc0_grctx.c nvc0_pm.c nvc0_vm.c nvc0_vram.c pscnv_chan.c pscnv_gem.c pscnv_ioctl.c pscnv_mem.c pscnv_mm.c pscnv_ramht.c pscnv_sysram.c pscnv_vm.c
-SRCS=$(HEADERS) $(C_SRCS) bus_if.h device_if.h pci_if.h opt_drm.h vnode_if.h
+C_SRCS=nouveau_bios.c nouveau_calc.c nouveau_connector.c nouveau_display.c nouveau_dma.c nouveau_dp.c nouveau_bsddrv.c nouveau_fbcon.c nouveau_hw.c nouveau_iic.c nouveau_irq.c nouveau_mem.c nouveau_perf.c nouveau_pm.c nouveau_state.c nouveau_temp.c nouveau_volt.c nv04_pm.c nv04_timer.c nv10_gpio.c nv40_counter.c nv50_calc.c nv50_chan.c nv50_crtc.c nv50_cursor.c nv50_dac.c nv50_display.c nv50_fifo.c nv50_gpio.c nv50_graph.c nv50_grctx.c nv50_pm.c nv50_sor.c nv50_vm.c nv50_vram.c nv84_crypt.c nv98_crypt.c nva3_pm.c nvc0_chan.c nvc0_copy.c nvc0_fifo.c nvc0_graph.c nvc0_grctx.c nvc0_pm.c nvc0_vm.c nvc0_vram.c pscnv_chan.c pscnv_gem.c pscnv_ioctl.c pscnv_mem.c pscnv_mm.c pscnv_ramht.c pscnv_sysram.c pscnv_vm.c
+SRCS=$(HEADERS) $(C_SRCS) bus_if.h device_if.h pci_if.h opt_drm.h vnode_if.h iicbb_if.h iicbus_if.h
.include <bsd.kmod.mk>
View
@@ -6,6 +6,7 @@ Anything touching i2c:
- hwmon (temperature) support
- nv04 tv/dfp
- displayport
+- iic doesn't respect udelay and timeout.. nouveau defines as 40 instead of 10
Not implemented at all:
- vga switcheroo / arbiter
@@ -15,5 +16,7 @@ TODO:
- fixup vm
- fixup io
- compile failures general
-- Maybe figure out wtf special casing nForce + old nv04 was for in nouveau_calc?
+- Maybe fix special casing nForce + old nv04 in nouveau_calc.c and nouveau_hw.c?
+- get outside i2c drm_encoder_slaves working properly (ch7006/sil164)
+- apci video support is lacking, impossible to get EDID through acpi video atm (for macbooks I guess?)
View
@@ -57,6 +57,10 @@ typedef DRM_SPINTYPE spinlock_t;
struct device_attribute {};
struct notifier_block {};
typedef struct pm_message_t { } pm_message_t;
+struct fb_info;
+struct fb_copyarea;
+struct fb_fillrect;
+struct fb_image;
struct vm_fault {};
struct vm_area_struct {};
@@ -430,6 +434,8 @@ ilog2(unsigned long x)
#endif /* _LINUX_LOG2_H_ */
+#define EREMOTEIO ENXIO
+
#ifndef _LINUX_ERR_H_
#define _LINUX_ERR_H_
View
@@ -2029,7 +2029,6 @@ init_sub_direct(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
static int
init_i2c_if(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
{
-#ifdef __linux__
/*
* INIT_I2C_IF opcode: 0x5E ('^')
*
@@ -2081,12 +2080,6 @@ init_i2c_if(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
offset, reg, val.byte, mask, data);
iexec->execute = ((val.byte & mask) == data);
-#else
- BIOSLOG(bios, "0x%04X: I2CReg: 0x%02X, Value: 0x%02X, "
- "Mask: 0x%02X, Data: 0x%02X not handled!\n",
- offset, reg, val.byte, mask, data);
- iexec->execute = 0;
-#endif
return 6;
}
@@ -2247,17 +2240,13 @@ nv04_init_compute_mem(struct nvbios *bios)
struct drm_device *dev = bios->dev;
uint32_t patt = 0xdeadbeef;
int i;
-#ifdef __linux__
struct io_mapping *fb;
/* Map the framebuffer aperture */
fb = io_mapping_create_wc(drm_get_resource_start(dev, 1),
drm_get_resource_len(dev, 1));
if (!fb)
return -ENOMEM;
-#else
- asdfasd
-#endif
/* Sequencer and refresh off */
NVWriteVgaSeq(dev, 0, 1, NVReadVgaSeq(dev, 0, 1) | 0x20);
@@ -3652,7 +3641,6 @@ init_zm_auxch(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
static int
init_i2c_long_if(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
{
-#ifdef __linux__
/*
* INIT_I2C_LONG_IF opcode: 0x9A ('')
*
@@ -3709,11 +3697,6 @@ init_i2c_long_if(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
offset, reghi, reglo, buf1[0], mask, data);
iexec->execute = ((buf1[0] & mask) == data);
-#else
- BIOSLOG(bios, "0x%04X: DCBI2CIndex: 0x%02X, I2CAddress: 0x%02X skipped due to no i2c yet\n",
- offset, i2c_index, i2c_address);
- iexec->execute = 0;
-#endif
return 7;
}
@@ -3927,7 +3910,11 @@ run_digital_op_script(struct drm_device *dev, uint16_t scriptptr,
NVWriteVgaCrtc5758(dev, head, 0, dcbent->index);
parse_init_table(bios, scriptptr, &iexec);
+#ifdef __linux__
nv04_dfp_bind_head(dev, dcbent, head, dl);
+#else
+ WARN("NYI\n");
+#endif
}
static int call_lvds_manufacturer_script(struct drm_device *dev, struct dcb_entry *dcbent, int head, enum LVDS_script script)
@@ -6482,8 +6469,10 @@ parse_dcb_table(struct drm_device *dev, struct nvbios *bios, bool twoHeads)
NV_INFO(dev, "Assuming a CRT output exists\n");
fabricate_vga_output(dcb, LEGACY_I2C_CRT, 1);
+#ifdef __linux__
if (nv04_tv_identify(dev, bios->legacy.i2c_indices.tv) >= 0)
fabricate_tv_output(dcb, twoHeads);
+#endif
return 0;
}
@@ -6546,6 +6535,7 @@ parse_dcb_table(struct drm_device *dev, struct nvbios *bios, bool twoHeads)
"adding all possible outputs\n");
fabricate_vga_output(dcb, LEGACY_I2C_CRT, 1);
+#ifdef __linux__
/*
* Attempt to detect TV before DVI because the test
* for the former is more accurate and it rules the
@@ -6555,7 +6545,9 @@ parse_dcb_table(struct drm_device *dev, struct nvbios *bios, bool twoHeads)
bios->legacy.i2c_indices.tv) >= 0)
fabricate_tv_output(dcb, twoHeads);
- else if (bios->tmds.output0_script_ptr ||
+ else
+#endif
+ if (bios->tmds.output0_script_ptr ||
bios->tmds.output1_script_ptr)
fabricate_dvi_i_output(dcb, twoHeads);
@@ -109,7 +109,9 @@ nouveau_connector_destroy(struct drm_connector *drm_connector)
NV_DEBUG_KMS(dev, "\n");
kfree(nv_connector->edid);
+#ifdef __linux__
drm_sysfs_connector_remove(drm_connector);
+#endif
drm_connector_cleanup(drm_connector);
kfree(drm_connector);
}
@@ -241,7 +243,11 @@ nouveau_connector_detect(struct drm_connector *connector, bool force)
i2c = nouveau_connector_ddc_detect(connector, &nv_encoder);
if (i2c) {
+#ifdef __linux__
nv_connector->edid = drm_get_edid(connector, &i2c->adapter);
+#else
+ nv_connector->edid = drm_get_edid(connector, i2c->adapter);
+#endif
drm_mode_connector_update_edid_property(connector,
nv_connector->edid);
if (!nv_connector->edid) {
@@ -1016,7 +1022,9 @@ nouveau_connector_create(struct drm_device *dev, int index)
nouveau_connector_set_polling(connector);
+#ifdef __linux__
drm_sysfs_connector_add(connector);
+#endif
dcb->drm = connector;
return dcb->drm;
View
@@ -579,6 +579,8 @@ nouveau_dp_auxch(struct nouveau_i2c_chan *auxch, int cmd, int addr,
return ret ? ret : (stat & NV50_AUXCH_STAT_REPLY);
}
+#ifdef __linux__
+
static int
nouveau_dp_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
{
@@ -640,3 +642,5 @@ const struct i2c_algorithm nouveau_dp_i2c_algo = {
.master_xfer = nouveau_dp_i2c_xfer,
.functionality = nouveau_dp_i2c_func
};
+
+#endif
View
@@ -498,7 +498,7 @@ struct drm_nouveau_private {
struct pscnv_fifo_engine *fifo;
struct pscnv_engine *engines[PSCNV_ENGINES_NUM];
int vm_ok;
- uint64_t vm_ramin_base;
+ uint64_t vm_ramin_base, dma_mask;
#if 0
struct nouveau_channel *channel;
#endif
@@ -859,6 +859,8 @@ static inline void nouveau_unregister_dsm_handler(void) {}
static inline bool nouveau_acpi_rom_supported(struct pci_dev *pdev) { return false; }
static inline int nouveau_acpi_get_bios_chunk(uint8_t *bios, int offset, int len) { return -EINVAL; }
static inline int nouveau_acpi_edid(struct drm_device *dev, struct drm_connector *connector) { return -EINVAL; }
+#else
+static inline int nouveau_acpi_edid(struct drm_device *dev, struct drm_connector *connector) { return -EINVAL; }
#endif
/* nouveau_backlight.c */
View
@@ -482,6 +482,7 @@ nouveau_hw_get_clock(struct drm_device *dev, enum pll_types plltype)
struct nouveau_pll_vals pllvals;
int ret;
+#ifdef __linux__ // TODO?
if (plltype == PLL_MEMORY &&
(dev->pci_device & 0x0ff0) == CHIPSET_NFORCE) {
uint32_t mpllP;
@@ -499,6 +500,7 @@ nouveau_hw_get_clock(struct drm_device *dev, enum pll_types plltype)
pci_read_config_dword(pci_get_bus_and_slot(0, 5), 0x4c, &clock);
return clock;
}
+#endif
ret = nouveau_hw_get_pllvals(dev, plltype, &pllvals);
if (ret)
View
@@ -25,8 +25,6 @@
#include "nouveau_drv.h"
#include "nouveau_i2c.h"
#include "nouveau_hw.h"
-
-#ifdef __linux__
#include <linux/module.h>
static void
@@ -319,16 +317,13 @@ nouveau_probe_i2c_addr(struct nouveau_i2c_chan *i2c, int addr)
return i2c_transfer(&i2c->adapter, msgs, 2) == 2;
}
-#endif
-
int
nouveau_i2c_identify(struct drm_device *dev, const char *what,
struct i2c_board_info *info,
bool (*match)(struct nouveau_i2c_chan *,
struct i2c_board_info *),
int index)
{
-#ifdef __linux__
struct nouveau_i2c_chan *i2c = nouveau_i2c_find(dev, index);
int i;
@@ -343,8 +338,5 @@ nouveau_i2c_identify(struct drm_device *dev, const char *what,
}
NV_DEBUG(dev, "No devices found.\n");
-#else
- NV_DEBUG(dev, "i2c not supported!\n");
-#endif
return -ENODEV;
}
View
@@ -34,24 +34,48 @@
#else /* __linux __ */
-struct i2c_adapter {};
-struct i2c_algo_bit_data {};
-struct i2c_board_info;
+struct i2c_algo_bit_data {
+ int (*getsda)(void *data);
+ int (*getscl)(void *data);
+ void (*setsda)(void *data, int sda);
+ void (*setscl)(void *data, int sdl);
+};
+struct i2c_board_info { const char *name; int addr; };
+#define I2C_BOARD_INFO(a, b) (a), (b)
+#define I2C_M_RD IIC_M_RD
+#define i2c_msg iic_msg
-#endif
-#include "drm_dp_helper.h"
+#include <dev/iicbus/iic.h>
+#include <dev/iicbus/iiconf.h>
+#include <dev/iicbus/iicbus.h>
+#include "iicbus_if.h"
+#include "iicbb_if.h"
-struct dcb_i2c_entry;
+static inline int i2c_transfer(device_t *dev, struct iic_msg *msg, int n) {
+ int ret;
+ ret = IICBUS_TRANSFER(*dev, msg, n);
+ return ret ? -ret : n;
+}
+
+#endif
struct nouveau_i2c_chan {
+#ifdef __linux__
struct i2c_adapter adapter;
+#else
+ device_t adapter, bus, iic_dev;
+ char name[32];
+#endif
struct drm_device *dev;
struct i2c_algo_bit_data bit;
unsigned rd;
unsigned wr;
unsigned data;
};
+#include "drm_dp_helper.h"
+
+struct dcb_i2c_entry;
int nouveau_i2c_init(struct drm_device *, struct dcb_i2c_entry *, int index);
void nouveau_i2c_fini(struct drm_device *, struct dcb_i2c_entry *);
struct nouveau_i2c_chan *nouveau_i2c_find(struct drm_device *, int index);
View
@@ -678,7 +678,7 @@ nv50_display_unk10_handler(struct drm_device *dev)
{
struct drm_nouveau_private *dev_priv = dev->dev_private;
u32 unk30 = nv_rd32(dev, 0x610030), mc;
- int i, crtc, or, type = OUTPUT_ANY;
+ int i, crtc, or = 0, type = OUTPUT_ANY;
NV_DEBUG_KMS(dev, "0x610030: 0x%08x\n", unk30);
dev_priv->evo_irq.dcb = NULL;
@@ -800,7 +800,7 @@ nv50_display_unk20_handler(struct drm_device *dev)
struct drm_nouveau_private *dev_priv = dev->dev_private;
u32 unk30 = nv_rd32(dev, 0x610030), tmp, pclk, script, mc;
struct dcb_entry *dcb;
- int i, crtc, or, type = OUTPUT_ANY;
+ int i, crtc, or = 0, type = OUTPUT_ANY;
NV_DEBUG_KMS(dev, "0x610030: 0x%08x\n", unk30);
dcb = dev_priv->evo_irq.dcb;
View
@@ -40,8 +40,8 @@ pscnv_mem_init(struct drm_device *dev)
struct drm_nouveau_private *dev_priv = dev->dev_private;
int ret;
-#ifdef __linux__
int dma_bits = 32;
+#ifdef __linux__
if (dev_priv->card_type >= NV_50 &&
pci_dma_supported(dev->pdev, DMA_BIT_MASK(40)))
dma_bits = 40;
@@ -51,7 +51,11 @@ pscnv_mem_init(struct drm_device *dev)
NV_ERROR(dev, "Error setting DMA mask: %d\n", ret);
return ret;
}
+#else
+ if (dev_priv->card_type >= NV_50)
+ dma_bits = 40;
#endif
+ dev_priv->dma_mask = DMA_BIT_MASK(dma_bits);
spin_lock_init(&dev_priv->pramin_lock);
mutex_init(&dev_priv->vram_mutex);
Oops, something went wrong.

0 comments on commit b14c58e

Please sign in to comment.