summaryrefslogtreecommitdiffstats
path: root/pci.c
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@dside.dyndns.org>2011-07-09 05:33:18 +0200
committerSuren A. Chilingaryan <csa@dside.dyndns.org>2011-07-09 05:33:18 +0200
commit02924fc49641ca9c000054a7a540b6f1eaa0e8f8 (patch)
tree986ba532752d7e19d85f77eea57f15579fe913d5 /pci.c
parent80d999195b2b1896fcd1878a44b0ece474fe678c (diff)
downloadipecamera-02924fc49641ca9c000054a7a540b6f1eaa0e8f8.tar.gz
ipecamera-02924fc49641ca9c000054a7a540b6f1eaa0e8f8.tar.bz2
ipecamera-02924fc49641ca9c000054a7a540b6f1eaa0e8f8.tar.xz
ipecamera-02924fc49641ca9c000054a7a540b6f1eaa0e8f8.zip
Support dynamic registers, support register offsets and multiregisters (bitmasks), list NWL DMA registers
Diffstat (limited to 'pci.c')
-rw-r--r--pci.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/pci.c b/pci.c
index 9426658..807e799 100644
--- a/pci.c
+++ b/pci.c
@@ -63,8 +63,8 @@ pcilib_t *pcilib_open(const char *device, pcilib_model_t model) {
if (!model) model = pcilib_get_model(ctx);
- ctx->model_info = pcilib_model + model;
-
+ memcpy(&ctx->model_info, pcilib_model + model, sizeof(pcilib_model_description_t));
+
api = pcilib_model[model].event_api;
if ((api)&&(api->init)) ctx->event_ctx = api->init(ctx);
}
@@ -73,7 +73,7 @@ pcilib_t *pcilib_open(const char *device, pcilib_model_t model) {
}
pcilib_model_description_t *pcilib_get_model_description(pcilib_t *ctx) {
- return ctx->model_info;
+ return &ctx->model_info;
}
const pcilib_board_info_t *pcilib_get_board_info(pcilib_t *ctx) {
@@ -221,8 +221,8 @@ int pcilib_map_register_space(pcilib_t *ctx) {
pcilib_register_bank_t i;
if (!ctx->reg_bar_mapped) {
- pcilib_model_t model = pcilib_get_model(ctx);
- pcilib_register_bank_description_t *banks = pcilib_model[model].banks;
+ pcilib_model_description_t *model_info = pcilib_get_model_description(ctx);
+ pcilib_register_bank_description_t *banks = model_info->banks;
for (i = 0; ((banks)&&(banks[i].access)); i++) {
// uint32_t buf[2];
@@ -400,13 +400,18 @@ void pcilib_close(pcilib_t *ctx) {
pcilib_bar_t i;
if (ctx) {
- pcilib_model_t model = pcilib_get_model(ctx);
- pcilib_event_api_description_t *eapi = pcilib_model[model].event_api;
- pcilib_dma_api_description_t *dapi = pcilib_model[model].dma_api;
+ pcilib_model_description_t *model_info = pcilib_get_model_description(ctx);
+ pcilib_event_api_description_t *eapi = model_info->event_api;
+ pcilib_dma_api_description_t *dapi = model_info->dma_api;
if ((eapi)&&(eapi->free)) eapi->free(ctx->event_ctx);
if ((dapi)&&(dapi->free)) dapi->free(ctx->dma_ctx);
+ if (ctx->model_info.registers != model_info->registers) {
+ free(ctx->model_info.registers);
+ ctx->model_info.registers = pcilib_model[ctx->model].registers;
+ }
+
while (ctx->kmem_list) {
pcilib_free_kernel_memory(ctx, ctx->kmem_list);
}