Lines Matching full:file

36 #include <linux/file.h>
86 * DOC: file operations
88 * Drivers must define the file operations structure that forms the DRM
101 * userspace through the file descriptor. They are used to send vblank event and
113 * No other file operations are supported by the DRM userspace API. Overall the
139 * drm_file_alloc - allocate file context
142 * This allocates a new DRM file context. It is not linked into any context and
152 struct drm_file *file; in drm_file_alloc() local
155 file = kzalloc(sizeof(*file), GFP_KERNEL); in drm_file_alloc()
156 if (!file) in drm_file_alloc()
159 file->pid = get_pid(task_pid(current)); in drm_file_alloc()
160 file->minor = minor; in drm_file_alloc()
163 file->authenticated = capable(CAP_SYS_ADMIN); in drm_file_alloc()
165 INIT_LIST_HEAD(&file->lhead); in drm_file_alloc()
166 INIT_LIST_HEAD(&file->fbs); in drm_file_alloc()
167 mutex_init(&file->fbs_lock); in drm_file_alloc()
168 INIT_LIST_HEAD(&file->blobs); in drm_file_alloc()
169 INIT_LIST_HEAD(&file->pending_event_list); in drm_file_alloc()
170 INIT_LIST_HEAD(&file->event_list); in drm_file_alloc()
171 init_waitqueue_head(&file->event_wait); in drm_file_alloc()
172 file->event_space = 4096; /* set aside 4k for event buffer */ in drm_file_alloc()
174 spin_lock_init(&file->master_lookup_lock); in drm_file_alloc()
175 mutex_init(&file->event_read_lock); in drm_file_alloc()
178 drm_gem_open(dev, file); in drm_file_alloc()
181 drm_syncobj_open(file); in drm_file_alloc()
183 drm_prime_init_file_private(&file->prime); in drm_file_alloc()
186 ret = dev->driver->open(dev, file); in drm_file_alloc()
191 return file; in drm_file_alloc()
194 drm_prime_destroy_file_private(&file->prime); in drm_file_alloc()
196 drm_syncobj_release(file); in drm_file_alloc()
198 drm_gem_release(dev, file); in drm_file_alloc()
199 put_pid(file->pid); in drm_file_alloc()
200 kfree(file); in drm_file_alloc()
230 * drm_file_free - free file context
231 * @file: context to free, or NULL
233 * This destroys and deallocates a DRM file context previously allocated via
239 void drm_file_free(struct drm_file *file) in drm_file_free() argument
243 if (!file) in drm_file_free()
246 dev = file->minor->dev; in drm_file_free()
250 (long)old_encode_dev(file->minor->kdev->devt), in drm_file_free()
256 dev->driver->preclose(dev, file); in drm_file_free()
260 drm_legacy_lock_release(dev, file->filp); in drm_file_free()
263 drm_legacy_reclaim_buffers(dev, file); in drm_file_free()
265 drm_events_release(file); in drm_file_free()
268 drm_fb_release(file); in drm_file_free()
269 drm_property_destroy_user_blobs(dev, file); in drm_file_free()
273 drm_syncobj_release(file); in drm_file_free()
276 drm_gem_release(dev, file); in drm_file_free()
278 drm_legacy_ctxbitmap_flush(dev, file); in drm_file_free()
280 if (drm_is_primary_client(file)) in drm_file_free()
281 drm_master_release(file); in drm_file_free()
284 dev->driver->postclose(dev, file); in drm_file_free()
286 drm_prime_destroy_file_private(&file->prime); in drm_file_free()
288 WARN_ON(!list_empty(&file->event_list)); in drm_file_free()
290 put_pid(file->pid); in drm_file_free()
291 kfree(file); in drm_file_free()
294 static void drm_close_helper(struct file *filp) in drm_close_helper()
322 * \param filp file pointer.
326 * Creates and initializes a drm_file structure for the file private data in \p
329 static int drm_open_helper(struct file *filp, struct drm_minor *minor) in drm_open_helper()
393 * drm_open - open method for DRM file
395 * @filp: file pointer.
398 * It looks up the correct DRM device and instantiates all the per-file
405 int drm_open(struct inode *inode, struct file *filp) in drm_open()
466 * drm_release - release method for DRM file
468 * @filp: file pointer.
471 * method. It frees any resources associated with the open file, and calls the
472 * &drm_driver.postclose driver callback. If this is the last open file for the
479 int drm_release(struct inode *inode, struct file *filp) in drm_release()
505 * drm_release_noglobal - release method for DRM file
507 * @filp: file pointer.
510 * method. It frees any resources associated with the open file prior to taking
512 * callback. If this is the last open file for the DRM device also proceeds to
519 int drm_release_noglobal(struct inode *inode, struct file *filp) in drm_release_noglobal()
539 * drm_read - read method for DRM file
540 * @filp: file pointer
563 ssize_t drm_read(struct file *filp, char __user *buffer, in drm_read()
633 * drm_poll - poll method for DRM file
634 * @filp: file pointer
646 * Mask of POLL flags indicating the current status of the file.
648 __poll_t drm_poll(struct file *filp, struct poll_table_struct *wait) in drm_poll()
665 * @file_priv: DRM file private data
707 * @file_priv: DRM file private data
804 * drm_send_event_timestamp_locked - send DRM event to file descriptor
811 * to its associated userspace DRM file. Callers must already hold
815 * corresponding DRM file is closed. Drivers need not worry about whether the
816 * DRM file for this event still exists and can call this function upon
827 * drm_send_event_locked - send DRM event to file descriptor
832 * to its associated userspace DRM file. Callers must already hold
836 * corresponding DRM file is closed. Drivers need not worry about whether the
837 * DRM file for this event still exists and can call this function upon
847 * drm_send_event - send DRM event to file descriptor
852 * to its associated userspace DRM file. This function acquires
857 * corresponding DRM file is closed. Drivers need not worry about whether the
858 * DRM file for this event still exists and can call this function upon
872 * mock_drm_getfile - Create a new struct file for the drm device
874 * @flags: file creation mode (O_RDWR etc)
876 * This create a new struct file that wraps a DRM file context around a
878 * invoking userspace. The struct file may be operated on using its f_op
883 * Pointer to newly created struct file, ERR_PTR on failure.
885 struct file *mock_drm_getfile(struct drm_minor *minor, unsigned int flags) in mock_drm_getfile()
889 struct file *file; in mock_drm_getfile() local
895 file = anon_inode_getfile("drm", dev->driver->fops, priv, flags); in mock_drm_getfile()
896 if (IS_ERR(file)) { in mock_drm_getfile()
898 return file; in mock_drm_getfile()
902 file->f_mapping = dev->anon_inode->i_mapping; in mock_drm_getfile()
905 priv->filp = file; in mock_drm_getfile()
907 return file; in mock_drm_getfile()