Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 The Android Open Source Project |
| 3 | * Copyright (c) 2011-2012 Code Aurora Forum. All rights reserved. |
| 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | #include <limits.h> |
| 19 | #include <unistd.h> |
| 20 | #include <fcntl.h> |
| 21 | #include <cutils/properties.h> |
| 22 | #include <sys/mman.h> |
| 23 | |
| 24 | #include <genlock.h> |
| 25 | |
| 26 | #include "gr.h" |
| 27 | #include "gpu.h" |
| 28 | #include "memalloc.h" |
| 29 | #include "alloc_controller.h" |
Ramkumar Radhakrishnan | 47573e2 | 2012-11-07 11:36:41 -0800 | [diff] [blame^] | 30 | #include <qdMetaData.h> |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 31 | |
| 32 | using namespace gralloc; |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 33 | |
| 34 | gpu_context_t::gpu_context_t(const private_module_t* module, |
Naseer Ahmed | 01d3fd3 | 2012-07-14 21:08:13 -0700 | [diff] [blame] | 35 | IAllocController* alloc_ctrl ) : |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 36 | mAllocCtrl(alloc_ctrl) |
| 37 | { |
| 38 | // Zero out the alloc_device_t |
| 39 | memset(static_cast<alloc_device_t*>(this), 0, sizeof(alloc_device_t)); |
| 40 | |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 41 | // Initialize the procs |
| 42 | common.tag = HARDWARE_DEVICE_TAG; |
| 43 | common.version = 0; |
| 44 | common.module = const_cast<hw_module_t*>(&module->base.common); |
| 45 | common.close = gralloc_close; |
| 46 | alloc = gralloc_alloc; |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 47 | free = gralloc_free; |
| 48 | |
| 49 | } |
| 50 | |
| 51 | int gpu_context_t::gralloc_alloc_framebuffer_locked(size_t size, int usage, |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 52 | buffer_handle_t* pHandle) |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 53 | { |
| 54 | private_module_t* m = reinterpret_cast<private_module_t*>(common.module); |
| 55 | |
Naseer Ahmed | 01d3fd3 | 2012-07-14 21:08:13 -0700 | [diff] [blame] | 56 | // we don't support framebuffer allocations with graphics heap flags |
| 57 | if (usage & GRALLOC_HEAP_MASK) { |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 58 | return -EINVAL; |
| 59 | } |
| 60 | |
| 61 | if (m->framebuffer == NULL) { |
| 62 | ALOGE("%s: Invalid framebuffer", __FUNCTION__); |
| 63 | return -EINVAL; |
| 64 | } |
| 65 | |
| 66 | const uint32_t bufferMask = m->bufferMask; |
| 67 | const uint32_t numBuffers = m->numBuffers; |
| 68 | size_t bufferSize = m->finfo.line_length * m->info.yres; |
| 69 | |
| 70 | //adreno needs FB size to be page aligned |
| 71 | bufferSize = roundUpToPageSize(bufferSize); |
| 72 | |
| 73 | if (numBuffers == 1) { |
| 74 | // If we have only one buffer, we never use page-flipping. Instead, |
| 75 | // we return a regular buffer which will be memcpy'ed to the main |
| 76 | // screen when post is called. |
| 77 | int newUsage = (usage & ~GRALLOC_USAGE_HW_FB) | GRALLOC_USAGE_HW_2D; |
| 78 | return gralloc_alloc_buffer(bufferSize, newUsage, pHandle, BUFFER_TYPE_UI, |
| 79 | m->fbFormat, m->info.xres, m->info.yres); |
| 80 | } |
| 81 | |
| 82 | if (bufferMask >= ((1LU<<numBuffers)-1)) { |
| 83 | // We ran out of buffers. |
| 84 | return -ENOMEM; |
| 85 | } |
| 86 | |
Naseer Ahmed | d7f8427 | 2012-12-13 13:09:53 -0500 | [diff] [blame] | 87 | // create a "fake" handle for it |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 88 | intptr_t vaddr = intptr_t(m->framebuffer->base); |
Naseer Ahmed | d7f8427 | 2012-12-13 13:09:53 -0500 | [diff] [blame] | 89 | private_handle_t* hnd = new private_handle_t( |
| 90 | dup(m->framebuffer->fd), bufferSize, |
| 91 | private_handle_t::PRIV_FLAGS_USES_ION | |
| 92 | private_handle_t::PRIV_FLAGS_FRAMEBUFFER, |
| 93 | BUFFER_TYPE_UI, m->fbFormat, m->info.xres, |
| 94 | m->info.yres); |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 95 | |
| 96 | // find a free slot |
| 97 | for (uint32_t i=0 ; i<numBuffers ; i++) { |
| 98 | if ((bufferMask & (1LU<<i)) == 0) { |
| 99 | m->bufferMask |= (1LU<<i); |
| 100 | break; |
| 101 | } |
| 102 | vaddr += bufferSize; |
| 103 | } |
| 104 | |
| 105 | hnd->base = vaddr; |
| 106 | hnd->offset = vaddr - intptr_t(m->framebuffer->base); |
| 107 | *pHandle = hnd; |
| 108 | return 0; |
| 109 | } |
| 110 | |
| 111 | |
| 112 | int gpu_context_t::gralloc_alloc_framebuffer(size_t size, int usage, |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 113 | buffer_handle_t* pHandle) |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 114 | { |
| 115 | private_module_t* m = reinterpret_cast<private_module_t*>(common.module); |
| 116 | pthread_mutex_lock(&m->lock); |
| 117 | int err = gralloc_alloc_framebuffer_locked(size, usage, pHandle); |
| 118 | pthread_mutex_unlock(&m->lock); |
| 119 | return err; |
| 120 | } |
| 121 | |
| 122 | int gpu_context_t::gralloc_alloc_buffer(size_t size, int usage, |
| 123 | buffer_handle_t* pHandle, int bufferType, |
| 124 | int format, int width, int height) |
| 125 | { |
| 126 | int err = 0; |
| 127 | int flags = 0; |
| 128 | size = roundUpToPageSize(size); |
| 129 | alloc_data data; |
| 130 | data.offset = 0; |
| 131 | data.fd = -1; |
| 132 | data.base = 0; |
| 133 | data.size = size; |
| 134 | if(format == HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED) |
| 135 | data.align = 8192; |
| 136 | else |
| 137 | data.align = getpagesize(); |
| 138 | data.pHandle = (unsigned int) pHandle; |
Naseer Ahmed | 01d3fd3 | 2012-07-14 21:08:13 -0700 | [diff] [blame] | 139 | err = mAllocCtrl->allocate(data, usage); |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 140 | |
Ramkumar Radhakrishnan | 47573e2 | 2012-11-07 11:36:41 -0800 | [diff] [blame^] | 141 | if (!err) { |
| 142 | /* allocate memory for enhancement data */ |
| 143 | alloc_data eData; |
| 144 | eData.fd = -1; |
| 145 | eData.base = 0; |
| 146 | eData.offset = 0; |
| 147 | eData.size = ROUND_UP_PAGESIZE(sizeof(MetaData_t)); |
| 148 | eData.pHandle = data.pHandle; |
| 149 | eData.align = getpagesize(); |
| 150 | int eDataUsage = GRALLOC_USAGE_PRIVATE_SYSTEM_HEAP; |
| 151 | int eDataErr = mAllocCtrl->allocate(eData, eDataUsage); |
| 152 | ALOGE_IF(eDataErr, "gralloc failed for eDataErr=%s", |
| 153 | strerror(-eDataErr)); |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 154 | |
Ramkumar Radhakrishnan | 47573e2 | 2012-11-07 11:36:41 -0800 | [diff] [blame^] | 155 | if (usage & GRALLOC_USAGE_PRIVATE_UNSYNCHRONIZED) { |
| 156 | flags |= private_handle_t::PRIV_FLAGS_UNSYNCHRONIZED; |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 157 | } |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 158 | |
Ramkumar Radhakrishnan | 47573e2 | 2012-11-07 11:36:41 -0800 | [diff] [blame^] | 159 | if (usage & GRALLOC_USAGE_PRIVATE_EXTERNAL_ONLY) { |
| 160 | flags |= private_handle_t::PRIV_FLAGS_EXTERNAL_ONLY; |
| 161 | //The EXTERNAL_BLOCK flag is always an add-on |
| 162 | if (usage & GRALLOC_USAGE_PRIVATE_EXTERNAL_BLOCK) { |
| 163 | flags |= private_handle_t::PRIV_FLAGS_EXTERNAL_BLOCK; |
| 164 | } |
| 165 | if (usage & GRALLOC_USAGE_PRIVATE_EXTERNAL_CC) { |
| 166 | flags |= private_handle_t::PRIV_FLAGS_EXTERNAL_CC; |
| 167 | } |
| 168 | } |
Naseer Ahmed | 5980250 | 2012-08-21 17:03:27 -0400 | [diff] [blame] | 169 | |
Ramkumar Radhakrishnan | 47573e2 | 2012-11-07 11:36:41 -0800 | [diff] [blame^] | 170 | if (usage & GRALLOC_USAGE_HW_VIDEO_ENCODER ) { |
| 171 | flags |= private_handle_t::PRIV_FLAGS_VIDEO_ENCODER; |
| 172 | } |
Naseer Ahmed | 5980250 | 2012-08-21 17:03:27 -0400 | [diff] [blame] | 173 | |
Ramkumar Radhakrishnan | 47573e2 | 2012-11-07 11:36:41 -0800 | [diff] [blame^] | 174 | if (usage & GRALLOC_USAGE_HW_CAMERA_WRITE) { |
| 175 | flags |= private_handle_t::PRIV_FLAGS_CAMERA_WRITE; |
| 176 | } |
Naseer Ahmed | 5980250 | 2012-08-21 17:03:27 -0400 | [diff] [blame] | 177 | |
Ramkumar Radhakrishnan | 47573e2 | 2012-11-07 11:36:41 -0800 | [diff] [blame^] | 178 | if (usage & GRALLOC_USAGE_HW_CAMERA_READ) { |
| 179 | flags |= private_handle_t::PRIV_FLAGS_CAMERA_READ; |
| 180 | } |
| 181 | |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 182 | flags |= data.allocType; |
Ramkumar Radhakrishnan | 47573e2 | 2012-11-07 11:36:41 -0800 | [diff] [blame^] | 183 | int eBaseAddr = int(eData.base) + eData.offset; |
| 184 | private_handle_t *hnd = new private_handle_t(data.fd, size, flags, |
| 185 | bufferType, format, width, height, eData.fd, eData.offset, |
| 186 | eBaseAddr); |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 187 | |
| 188 | hnd->offset = data.offset; |
| 189 | hnd->base = int(data.base) + data.offset; |
| 190 | *pHandle = hnd; |
| 191 | } |
| 192 | |
| 193 | ALOGE_IF(err, "gralloc failed err=%s", strerror(-err)); |
Ramkumar Radhakrishnan | 47573e2 | 2012-11-07 11:36:41 -0800 | [diff] [blame^] | 194 | |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 195 | return err; |
| 196 | } |
| 197 | |
| 198 | void gpu_context_t::getGrallocInformationFromFormat(int inputFormat, |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 199 | int *bufferType) |
| 200 | { |
| 201 | *bufferType = BUFFER_TYPE_VIDEO; |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 202 | |
Naseer Ahmed | 65f1656 | 2012-06-15 20:53:42 -0700 | [diff] [blame] | 203 | if (inputFormat < 0x7) { |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 204 | // RGB formats |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 205 | *bufferType = BUFFER_TYPE_UI; |
| 206 | } else if ((inputFormat == HAL_PIXEL_FORMAT_R_8) || |
| 207 | (inputFormat == HAL_PIXEL_FORMAT_RG_88)) { |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 208 | *bufferType = BUFFER_TYPE_UI; |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | int gpu_context_t::alloc_impl(int w, int h, int format, int usage, |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 213 | buffer_handle_t* pHandle, int* pStride, |
| 214 | size_t bufferSize) { |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 215 | if (!pHandle || !pStride) |
| 216 | return -EINVAL; |
| 217 | |
| 218 | size_t size; |
| 219 | int alignedw, alignedh; |
Naseer Ahmed | 5980250 | 2012-08-21 17:03:27 -0400 | [diff] [blame] | 220 | int grallocFormat = format; |
| 221 | int bufferType; |
Naseer Ahmed | 5980250 | 2012-08-21 17:03:27 -0400 | [diff] [blame] | 222 | |
Saurabh Shah | aedf236 | 2012-09-05 11:30:59 -0700 | [diff] [blame] | 223 | //If input format is HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED then based on |
| 224 | //the usage bits, gralloc assigns a format. |
| 225 | if(format == HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED) { |
| 226 | if(usage & GRALLOC_USAGE_HW_VIDEO_ENCODER) |
| 227 | grallocFormat = HAL_PIXEL_FORMAT_YCbCr_420_SP; //NV12 |
| 228 | else if(usage & GRALLOC_USAGE_HW_CAMERA_READ) |
| 229 | grallocFormat = HAL_PIXEL_FORMAT_YCrCb_420_SP; //NV21 |
| 230 | else if(usage & GRALLOC_USAGE_HW_CAMERA_WRITE) |
| 231 | grallocFormat = HAL_PIXEL_FORMAT_YCrCb_420_SP; //NV21 |
| 232 | } |
Naseer Ahmed | 5980250 | 2012-08-21 17:03:27 -0400 | [diff] [blame] | 233 | |
Saurabh Shah | aedf236 | 2012-09-05 11:30:59 -0700 | [diff] [blame] | 234 | getGrallocInformationFromFormat(grallocFormat, &bufferType); |
Naseer Ahmed | 5980250 | 2012-08-21 17:03:27 -0400 | [diff] [blame] | 235 | size = getBufferSizeAndDimensions(w, h, grallocFormat, alignedw, alignedh); |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 236 | |
| 237 | if ((ssize_t)size <= 0) |
| 238 | return -EINVAL; |
| 239 | size = (bufferSize >= size)? bufferSize : size; |
| 240 | |
| 241 | // All buffers marked as protected or for external |
| 242 | // display need to go to overlay |
| 243 | if ((usage & GRALLOC_USAGE_EXTERNAL_DISP) || |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 244 | (usage & GRALLOC_USAGE_PROTECTED) || |
| 245 | (usage & GRALLOC_USAGE_PRIVATE_CP_BUFFER)) { |
| 246 | bufferType = BUFFER_TYPE_VIDEO; |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 247 | } |
Naseer Ahmed | 768619e | 2012-11-28 17:02:52 -0500 | [diff] [blame] | 248 | |
| 249 | int err = gralloc_alloc_buffer(size, usage, pHandle, bufferType, |
| 250 | grallocFormat, alignedw, alignedh); |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 251 | |
| 252 | if (err < 0) { |
| 253 | return err; |
| 254 | } |
| 255 | |
| 256 | // Create a genlock lock for this buffer handle. |
| 257 | err = genlock_create_lock((native_handle_t*)(*pHandle)); |
| 258 | if (err) { |
| 259 | ALOGE("%s: genlock_create_lock failed", __FUNCTION__); |
| 260 | free_impl(reinterpret_cast<private_handle_t*>(pHandle)); |
| 261 | return err; |
| 262 | } |
| 263 | *pStride = alignedw; |
| 264 | return 0; |
| 265 | } |
| 266 | |
| 267 | int gpu_context_t::free_impl(private_handle_t const* hnd) { |
| 268 | private_module_t* m = reinterpret_cast<private_module_t*>(common.module); |
| 269 | if (hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER) { |
| 270 | // free this buffer |
| 271 | const size_t bufferSize = m->finfo.line_length * m->info.yres; |
| 272 | int index = (hnd->base - m->framebuffer->base) / bufferSize; |
| 273 | m->bufferMask &= ~(1<<index); |
| 274 | } else { |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 275 | terminateBuffer(&m->base, const_cast<private_handle_t*>(hnd)); |
Naseer Ahmed | 01d3fd3 | 2012-07-14 21:08:13 -0700 | [diff] [blame] | 276 | IMemAlloc* memalloc = mAllocCtrl->getAllocator(hnd->flags); |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 277 | int err = memalloc->free_buffer((void*)hnd->base, (size_t) hnd->size, |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 278 | hnd->offset, hnd->fd); |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 279 | if(err) |
| 280 | return err; |
Ramkumar Radhakrishnan | 47573e2 | 2012-11-07 11:36:41 -0800 | [diff] [blame^] | 281 | // free the metadata space |
| 282 | unsigned long size = ROUND_UP_PAGESIZE(sizeof(MetaData_t)); |
| 283 | err = memalloc->free_buffer((void*)hnd->base_metadata, |
| 284 | (size_t) size, hnd->offset_metadata, |
| 285 | hnd->fd_metadata); |
| 286 | if (err) |
| 287 | return err; |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 288 | } |
| 289 | |
| 290 | // Release the genlock |
| 291 | int err = genlock_release_lock((native_handle_t*)hnd); |
| 292 | if (err) { |
| 293 | ALOGE("%s: genlock_release_lock failed", __FUNCTION__); |
| 294 | } |
| 295 | |
| 296 | delete hnd; |
| 297 | return 0; |
| 298 | } |
| 299 | |
| 300 | int gpu_context_t::gralloc_alloc(alloc_device_t* dev, int w, int h, int format, |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 301 | int usage, buffer_handle_t* pHandle, |
| 302 | int* pStride) |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 303 | { |
| 304 | if (!dev) { |
| 305 | return -EINVAL; |
| 306 | } |
| 307 | gpu_context_t* gpu = reinterpret_cast<gpu_context_t*>(dev); |
| 308 | return gpu->alloc_impl(w, h, format, usage, pHandle, pStride, 0); |
| 309 | } |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 310 | int gpu_context_t::gralloc_alloc_size(alloc_device_t* dev, int w, int h, |
| 311 | int format, int usage, |
| 312 | buffer_handle_t* pHandle, int* pStride, |
| 313 | int bufferSize) |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 314 | { |
| 315 | if (!dev) { |
| 316 | return -EINVAL; |
| 317 | } |
| 318 | gpu_context_t* gpu = reinterpret_cast<gpu_context_t*>(dev); |
| 319 | return gpu->alloc_impl(w, h, format, usage, pHandle, pStride, bufferSize); |
| 320 | } |
| 321 | |
| 322 | |
| 323 | int gpu_context_t::gralloc_free(alloc_device_t* dev, |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 324 | buffer_handle_t handle) |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 325 | { |
| 326 | if (private_handle_t::validate(handle) < 0) |
| 327 | return -EINVAL; |
| 328 | |
| 329 | private_handle_t const* hnd = reinterpret_cast<private_handle_t const*>(handle); |
| 330 | gpu_context_t* gpu = reinterpret_cast<gpu_context_t*>(dev); |
| 331 | return gpu->free_impl(hnd); |
| 332 | } |
| 333 | |
| 334 | /*****************************************************************************/ |
| 335 | |
| 336 | int gpu_context_t::gralloc_close(struct hw_device_t *dev) |
| 337 | { |
| 338 | gpu_context_t* ctx = reinterpret_cast<gpu_context_t*>(dev); |
| 339 | if (ctx) { |
| 340 | /* TODO: keep a list of all buffer_handle_t created, and free them |
| 341 | * all here. |
| 342 | */ |
| 343 | delete ctx; |
| 344 | } |
| 345 | return 0; |
| 346 | } |
| 347 | |