brucech...@via.com.tw wrote:
> Hello Sirs:
>     This patch is to add the interface to communicate with V4L and DDMPEG. 
>
> Signed-off-by Bruce C. Chang <brucech...@via.com.tw>
>
> diff -ruN old/drivers/gpu/drm/via/via_dma.c new/drivers/gpu/drm/via/via_dma.c
> --- old/drivers/gpu/drm/via/via_dma.c 2009-10-22 10:42:10.000000000 +0800
> +++ new/drivers/gpu/drm/via/via_dma.c 2009-10-22 12:48:26.000000000 +0800
> @@ -824,6 +824,7 @@
>       DRM_IOCTL_DEF(DRM_VIA_FB_INIT, via_fb_init, DRM_AUTH|DRM_MASTER),
>       DRM_IOCTL_DEF(DRM_VIA_MAP_INIT, via_map_init, DRM_AUTH|DRM_MASTER),
>       DRM_IOCTL_DEF(DRM_VIA_DEC_FUTEX, via_decoder_futex, DRM_AUTH),
> +     DRM_IOCTL_DEF(DRM_VIA_GET_INFO, via_get_drm_info, DRM_AUTH),
>   

This is a backwards-compatible interface change, so please bump the 
minor version number as well.

>       DRM_IOCTL_DEF(DRM_VIA_DMA_INIT, via_dma_init, DRM_AUTH),
>       DRM_IOCTL_DEF(DRM_VIA_CMDBUFFER, via_cmdbuffer, DRM_AUTH),
>       DRM_IOCTL_DEF(DRM_VIA_FLUSH, via_flush_ioctl, DRM_AUTH),
> diff -ruN old/drivers/gpu/drm/via/via_drv.h new/drivers/gpu/drm/via/via_drv.h
> --- old/drivers/gpu/drm/via/via_drv.h 2009-10-22 10:42:10.000000000 +0800
> +++ new/drivers/gpu/drm/via/via_drv.h 2009-10-22 12:48:26.000000000 +0800
> @@ -121,6 +121,8 @@
>  extern int via_agp_init(struct drm_device *dev, void *data, struct drm_file 
> *file_priv);
>  extern int via_map_init(struct drm_device *dev, void *data, struct drm_file 
> *file_priv);
>  extern int via_decoder_futex(struct drm_device *dev, void *data, struct 
> drm_file *file_priv);
> +extern int via_get_drm_info(struct drm_device *dev, void *data,
> +     struct drm_file *file_priv);
>  extern int via_wait_irq(struct drm_device *dev, void *data, struct drm_file 
> *file_priv);
>  extern int via_dma_blit_sync( struct drm_device *dev, void *data, struct 
> drm_file *file_priv );
>  extern int via_dma_blit( struct drm_device *dev, void *data, struct drm_file 
> *file_priv );
> diff -ruN old/drivers/gpu/drm/via/via_map.c new/drivers/gpu/drm/via/via_map.c
> --- old/drivers/gpu/drm/via/via_map.c 2009-10-22 10:42:10.000000000 +0800
> +++ new/drivers/gpu/drm/via/via_map.c 2009-10-22 12:48:26.000000000 +0800
> @@ -143,3 +143,21 @@
>  
>       return 0;
>  }
> +
> +/* This function is for via another video decoder driver to get information 
> */
> +int via_get_drm_info(struct drm_device *dev, void *data,
> +     struct drm_file *file_priv)
> +{
> +     drm_via_private_t *dev_priv = (drm_via_private_t *)dev->dev_private;
> +     struct drm_via_info *info = data;
> +
> +     if (!dev_priv->initialize || !dev->agp_buffer_map)
> +             return -EINVAL;
> +
> +     info->RegSize = dev_priv->mmio->size;
> +     info->AgpSize = dev->agp_buffer_map->size;
> +     info->RegHandle = dev_priv->mmio->offset;
> +     info->AgpHandle = dev->agp_buffer_map->offset;
> +
> +     return 0;
> +}
>   

Please add a check to make sure the register map is exported read-only.


> diff -ruN old/drivers/gpu/drm/via/via_mm.c new/drivers/gpu/drm/via/via_mm.c
> --- old/drivers/gpu/drm/via/via_mm.c  2009-10-22 10:42:10.000000000 +0800
> +++ new/drivers/gpu/drm/via/via_mm.c  2009-10-22 12:48:26.000000000 +0800
> @@ -57,6 +57,8 @@
>       DRM_DEBUG("offset = %u, size = %u\n", agp->offset, agp->size);
>       return 0;
>  }
> +static void *global_dev;
> +static void *global_file_priv;
>   

Hmm.
This needs a callback to v4l to make sure v4l releases all its memory 
when global_file_priv or global_dev goes away.
What may happen is that the X server shuts down, and then all memory 
regions will be freed, but v4l may continue to use global_file_priv, 
which doesn't exist anymore and cause a kernel oops.

>  
>  int via_fb_init(struct drm_device *dev, void *data, struct drm_file 
> *file_priv)
>  {
> @@ -79,6 +81,8 @@
>  
>       mutex_unlock(&dev->struct_mutex);
>       DRM_DEBUG("offset = %u, size = %u\n", fb->offset, fb->size);
> +     global_dev = dev;
> +     global_file_priv = file_priv;
>  
>       return 0;
>  
> @@ -291,3 +295,28 @@
>       mutex_unlock(&dev->struct_mutex);
>       return;
>  }
> +
> +/* These two function is exported for via V4L module communication */
> +static int via_fb_alloc(drm_via_mem_t *mem)
> +{
> +     struct drm_device *dev = global_dev;
> +     struct drm_file *file_priv = global_file_priv;
> +
> +     if (dev && file_priv)
> +             return via_mem_alloc(dev, mem, file_priv);
> +     else
> +             return -EINVAL;
> +}
> +EXPORT_SYMBOL(via_fb_alloc);
> +
> +static int via_fb_free(drm_via_mem_t *mem)
> +{
> +     struct drm_device *dev = global_dev;
> +     struct drm_file *file_priv = global_file_priv;
> +
> +     if (dev && file_priv)
> +             return via_mem_free(dev, mem, file_priv);
> +     else
> +             return -EINVAL;
> +}
> +EXPORT_SYMBOL(via_fb_free);
> diff -ruN old/include/drm/via_drm.h new/include/drm/via_drm.h
> --- old/include/drm/via_drm.h 2009-10-22 10:42:10.000000000 +0800
> +++ new/include/drm/via_drm.h 2009-10-22 12:52:51.000000000 +0800
> @@ -53,6 +53,12 @@
>  #define VIA_LOG_MIN_TEX_REGION_SIZE 16
>  #endif
>  
> +struct drm_via_info {
> +     unsigned long AgpHandle;
> +     unsigned long AgpSize;
> +     unsigned long RegHandle;
> +     unsigned long RegSize;
> +} ;
>   

Don't use unsigned long. It has different sizes in 64-bit and 32-bit 
systems.
Use __u64 or uint64_t.


>  #define VIA_UPLOAD_TEX0IMAGE  0x1    /* handled clientside */
>  #define VIA_UPLOAD_TEX1IMAGE  0x2    /* handled clientside */
>  #define VIA_UPLOAD_CTX        0x4
> @@ -69,7 +75,7 @@
>  #define DRM_VIA_FB_INIT              0x03
>  #define DRM_VIA_MAP_INIT     0x04
>  #define DRM_VIA_DEC_FUTEX       0x05
> -#define NOT_USED
> +#define DRM_VIA_GET_INFO    0x06
>  #define DRM_VIA_DMA_INIT     0x07
>  #define DRM_VIA_CMDBUFFER    0x08
>  #define DRM_VIA_FLUSH                0x09
> @@ -86,6 +92,8 @@
>  #define DRM_IOCTL_VIA_FB_INIT          DRM_IOWR(DRM_COMMAND_BASE + 
> DRM_VIA_FB_INIT, drm_via_fb_t)
>  #define DRM_IOCTL_VIA_MAP_INIT         DRM_IOWR(DRM_COMMAND_BASE + 
> DRM_VIA_MAP_INIT, drm_via_init_t)
>  #define DRM_IOCTL_VIA_DEC_FUTEX   DRM_IOW( DRM_COMMAND_BASE + 
> DRM_VIA_DEC_FUTEX, drm_via_futex_t)
> +#define DRM_IOCTL_VIA_GET_INFO    DRM_IOR(DRM_COMMAND_BASE + \
> +                                     DRM_VIA_GET_INFO, struct drm_via_info)
>  #define DRM_IOCTL_VIA_DMA_INIT         DRM_IOWR(DRM_COMMAND_BASE + 
> DRM_VIA_DMA_INIT, drm_via_dma_init_t)
>  #define DRM_IOCTL_VIA_CMDBUFFER        DRM_IOW( DRM_COMMAND_BASE + 
> DRM_VIA_CMDBUFFER, drm_via_cmdbuffer_t)
>  #define DRM_IOCTL_VIA_FLUSH    DRM_IO(  DRM_COMMAND_BASE + DRM_VIA_FLUSH)
>
> Thanks and Best Regards 
> =================================================
> Bruce C. Chang(張祖明)
> VIA Technologies, Inc. 
> Address: 1F, 531, Chung-Cheng Road, Hsin-Tien, 231 Taipei
> Tel: +886-2-22185452 Ext 7323
> Mobile: +886-968343824
> Fax: +886-2-22186282
> Skype: Bruce.C.Chang
> Email: brucech...@via.com.tw
>   




------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
--
_______________________________________________
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel

Reply via email to