Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/gdev-axe'
Browse files Browse the repository at this point in the history
  • Loading branch information
shinpei0208 committed May 16, 2013
2 parents 3865611 + a6f20b6 commit c67210a
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 2 deletions.
18 changes: 16 additions & 2 deletions lib/user/nvrm/nvrm_gdev.c
Expand Up @@ -37,6 +37,8 @@ int gdev_raw_query(struct gdev_device *gdev, uint32_t type, uint64_t *result)
{
struct nvrm_device *dev = gdev->priv;
uint32_t chip_major, chip_minor;
uint16_t vendor_id, device_id;
uint64_t fb_size;
int count;

switch (type) {
Expand All @@ -46,8 +48,10 @@ int gdev_raw_query(struct gdev_device *gdev, uint32_t type, uint64_t *result)
*result = count;
break;
case GDEV_QUERY_DEVICE_MEM_SIZE:
/* XXX */
goto fail;
if (nvrm_device_get_fb_size(dev, &fb_size))
goto fail;
*result = fb_size;
break;
case GDEV_QUERY_DMA_MEM_SIZE:
/* XXX */
goto fail;
Expand All @@ -56,6 +60,16 @@ int gdev_raw_query(struct gdev_device *gdev, uint32_t type, uint64_t *result)
goto fail;
*result = chip_major | chip_minor;
break;
case GDEV_QUERY_PCI_VENDOR:
if (nvrm_device_get_vendor_id(dev, &vendor_id))
goto fail;
*result = vendor_id;
break;
case GDEV_QUERY_PCI_DEVICE:
if (nvrm_device_get_device_id(dev, &device_id))
goto fail;
*result = device_id;
break;
default:
goto fail;
}
Expand Down
30 changes: 30 additions & 0 deletions nvrm/ioctl.c
Expand Up @@ -141,6 +141,36 @@ int nvrm_ioctl_card_info(struct nvrm_context *ctx) {
return 0;
}

int nvrm_ioctl_get_fb_size(struct nvrm_context *ctx, int idx, uint64_t *size) {
struct nvrm_ioctl_card_info arg = { {
{ 0xffffffff },
} };
if (ioctl(ctx->fd_ctl, NVRM_IOCTL_CARD_INFO, &arg) < 0)
return -1;
*size = arg.card[idx].fb_size;
return 0;
}

int nvrm_ioctl_get_vendor_id(struct nvrm_context *ctx, int idx, uint16_t *id) {
struct nvrm_ioctl_card_info arg = { {
{ 0xffffffff },
} };
if (ioctl(ctx->fd_ctl, NVRM_IOCTL_CARD_INFO, &arg) < 0)
return -1;
*id = arg.card[idx].vendor_id;
return 0;
}

int nvrm_ioctl_get_device_id(struct nvrm_context *ctx, int idx, uint16_t *id) {
struct nvrm_ioctl_card_info arg = { {
{ 0xffffffff },
} };
if (ioctl(ctx->fd_ctl, NVRM_IOCTL_CARD_INFO, &arg) < 0)
return -1;
*id = arg.card[idx].device_id;
return 0;
}

int nvrm_ioctl_env_info(struct nvrm_context *ctx, uint32_t *pat_supported) {
struct nvrm_ioctl_env_info arg = {
};
Expand Down
21 changes: 21 additions & 0 deletions nvrm/mthd.c
Expand Up @@ -64,6 +64,27 @@ int nvrm_device_get_chipset(struct nvrm_device *dev, uint32_t *major, uint32_t *
return 0;
}

int nvrm_device_get_fb_size(struct nvrm_device *dev, uint64_t *fb_size) {
int res = nvrm_ioctl_get_fb_size(dev->ctx, dev->idx, fb_size);
if (res)
return res;
return 0;
}

int nvrm_device_get_vendor_id(struct nvrm_device *dev, uint16_t *vendor_id) {
int res = nvrm_ioctl_get_vendor_id(dev->ctx, dev->idx, vendor_id);
if (res)
return res;
return 0;
}

int nvrm_device_get_device_id(struct nvrm_device *dev, uint16_t *device_id) {
int res = nvrm_ioctl_get_device_id(dev->ctx, dev->idx, device_id);
if (res)
return res;
return 0;
}

int nvrm_device_get_gpc_mask(struct nvrm_device *dev, uint32_t *mask) {
struct nvrm_mthd_subdevice_get_gpc_mask arg = {
};
Expand Down
3 changes: 3 additions & 0 deletions nvrm/nvrm.h
Expand Up @@ -41,6 +41,9 @@ int nvrm_num_devices(struct nvrm_context *ctx);
struct nvrm_device *nvrm_device_open(struct nvrm_context *ctx, int idx);
void nvrm_device_close(struct nvrm_device *dev);
int nvrm_device_get_chipset(struct nvrm_device *dev, uint32_t *major, uint32_t *minor, uint32_t *stepping);
int nvrm_device_get_fb_size(struct nvrm_device *dev, uint64_t *fb_size);
int nvrm_device_get_vendor_id(struct nvrm_device *dev, uint16_t *vendor_id);
int nvrm_device_get_device_id(struct nvrm_device *dev, uint16_t *device_id);
int nvrm_device_get_gpc_mask(struct nvrm_device *dev, uint32_t *mask);
int nvrm_device_get_gpc_tp_mask(struct nvrm_device *dev, int gpc_id, uint32_t *mask);
int nvrm_device_get_total_tp_count(struct nvrm_device *dev, int *count);
Expand Down
3 changes: 3 additions & 0 deletions nvrm/nvrm_priv.h
Expand Up @@ -104,6 +104,9 @@ int nvrm_ioctl_create(struct nvrm_context *ctx, uint32_t parent, uint32_t handle
int nvrm_ioctl_destroy(struct nvrm_context *ctx, uint32_t parent, uint32_t handle);
int nvrm_ioctl_unk4d(struct nvrm_context *ctx, uint32_t handle, const char *str);
int nvrm_ioctl_card_info(struct nvrm_context *ctx);
int nvrm_ioctl_get_fb_size(struct nvrm_context *ctx, int idx, uint64_t *size);
int nvrm_ioctl_get_vendor_id(struct nvrm_context *ctx, int idx, uint16_t *id);
int nvrm_ioctl_get_device_id(struct nvrm_context *ctx, int idx, uint16_t *id);
int nvrm_ioctl_env_info(struct nvrm_context *ctx, uint32_t *pat_supported);
int nvrm_ioctl_check_version_str(struct nvrm_context *ctx, uint32_t cmd, const char *vernum);
int nvrm_ioctl_memory(struct nvrm_context *ctx, uint32_t parent, uint32_t vspace, uint32_t handle, uint32_t flags1, uint32_t flags2, uint64_t base, uint64_t size);
Expand Down

0 comments on commit c67210a

Please sign in to comment.