1ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* 215c7eb9ba46119290695b650d23180884f1156faArun Kumar K.R * Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. 3ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 4ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * Redistribution and use in source and binary forms, with or without 5ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * modification, are permitted provided that the following conditions are 6ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * met: 7ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * * Redistributions of source code must retain the above copyright 8ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * notice, this list of conditions and the following disclaimer. 9ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * * Redistributions in binary form must reproduce the above 10ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * copyright notice, this list of conditions and the following 11ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * disclaimer in the documentation and/or other materials provided 12ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * with the distribution. 13ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * * Neither the name of The Linux Foundation nor the names of its 14ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * contributors may be used to endorse or promote products derived 15ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * from this software without specific prior written permission. 16ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * 17ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 18ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 20ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 21ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 24ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 25ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 26ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 27ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson */ 29ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 30ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#ifndef GRALLOC_IONALLOC_H 31ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#define GRALLOC_IONALLOC_H 32ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 33ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#include <linux/msm_ion.h> 34ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#include "memalloc.h" 35ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#include "gr.h" 36ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 37ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsonnamespace gralloc { 38ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 39ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsonclass IonAlloc : public IMemAlloc { 40ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 41ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson public: 42ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson virtual int alloc_buffer(alloc_data& data); 43ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 4492e456fd92a6231dbf5d9de5289ed2f84841a804Saurabh Shah virtual int free_buffer(void *base, unsigned int size, 4592e456fd92a6231dbf5d9de5289ed2f84841a804Saurabh Shah unsigned int offset, int fd); 46ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 4792e456fd92a6231dbf5d9de5289ed2f84841a804Saurabh Shah virtual int map_buffer(void **pBase, unsigned int size, 4892e456fd92a6231dbf5d9de5289ed2f84841a804Saurabh Shah unsigned int offset, int fd); 49ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 5092e456fd92a6231dbf5d9de5289ed2f84841a804Saurabh Shah virtual int unmap_buffer(void *base, unsigned int size, 5192e456fd92a6231dbf5d9de5289ed2f84841a804Saurabh Shah unsigned int offset); 52ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 5392e456fd92a6231dbf5d9de5289ed2f84841a804Saurabh Shah virtual int clean_buffer(void*base, unsigned int size, 5492e456fd92a6231dbf5d9de5289ed2f84841a804Saurabh Shah unsigned int offset, int fd, int op); 55ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 56ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson IonAlloc() { mIonFd = FD_INIT; } 57ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 58ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson ~IonAlloc() { close_device(); } 59ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 60ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson private: 61ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson int mIonFd; 62ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 63ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson int open_device(); 64ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 65ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson void close_device(); 66ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 67ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson mutable Locker mLock; 68ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 69ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson}; 70ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 71ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson} 72ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 73ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#endif /* GRALLOC_IONALLOC_H */ 74ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 75