os/kernelhwsrv/kernel/eka/include/d32camerasc.inl
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// e32\include\d32camerasc.inl
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
inline TVersion RDevCameraSc::VersionRequired()
sl@0
    19
	{
sl@0
    20
	const TInt KCameraMajorVersionNumber=1;
sl@0
    21
	const TInt KCameraMinorVersionNumber=0;
sl@0
    22
	const TInt KCameraBuildVersionNumber=KE32BuildVersionNumber;
sl@0
    23
	return TVersion(KCameraMajorVersionNumber,KCameraMinorVersionNumber,KCameraBuildVersionNumber);
sl@0
    24
	}
sl@0
    25
sl@0
    26
#ifndef __KERNEL_MODE__
sl@0
    27
sl@0
    28
sl@0
    29
inline RDevCameraSc::RDevCameraSc()
sl@0
    30
: RBusLogicalChannel()
sl@0
    31
	{
sl@0
    32
	iCameraCaps = NULL;
sl@0
    33
	iCapsSize = 0;
sl@0
    34
	}
sl@0
    35
sl@0
    36
inline TInt RDevCameraSc::Open(TInt aUnit)
sl@0
    37
	{
sl@0
    38
	TInt r=DoCreate(KDevCameraScName,VersionRequired(),aUnit,NULL,NULL,EOwnerThread);
sl@0
    39
	if (KErrNone == r)
sl@0
    40
		{
sl@0
    41
		// Obtain the Capability structure size then allocate memory for it on client side
sl@0
    42
		r=iCapsSize=DoControl(EControlCapsSize);		
sl@0
    43
		if (KErrNone > r)
sl@0
    44
			{
sl@0
    45
			iCapsSize = 0;
sl@0
    46
			return r;
sl@0
    47
			}
sl@0
    48
sl@0
    49
		TAny* capsBufPtr = User::Alloc(iCapsSize);
sl@0
    50
		if(NULL == capsBufPtr)
sl@0
    51
			{
sl@0
    52
			Close();
sl@0
    53
			return KErrNoMemory;
sl@0
    54
			}
sl@0
    55
sl@0
    56
		TPtr8 capsPtr((TUint8*)capsBufPtr, iCapsSize, iCapsSize);
sl@0
    57
		// Fill the Capability structure
sl@0
    58
		r = DoControl(EControlCaps,(TAny*)&capsPtr);
sl@0
    59
		if (KErrNone > r)
sl@0
    60
			{
sl@0
    61
			iCapsSize = 0;
sl@0
    62
			return r;
sl@0
    63
			}
sl@0
    64
		iCameraCaps = (TCameraCapsV02*) capsPtr.Ptr();
sl@0
    65
		}
sl@0
    66
sl@0
    67
	return r;
sl@0
    68
	}
sl@0
    69
sl@0
    70
inline void RDevCameraSc::Close()
sl@0
    71
	{
sl@0
    72
	if (iCameraCaps != NULL)
sl@0
    73
		{
sl@0
    74
		User::Free(iCameraCaps);
sl@0
    75
		iCameraCaps = NULL;
sl@0
    76
		}
sl@0
    77
	iCapsSize = 0;
sl@0
    78
	RBusLogicalChannel::Close();
sl@0
    79
	}
sl@0
    80
sl@0
    81
inline TInt RDevCameraSc::Caps(TDes8& aCapsBuf)
sl@0
    82
	{
sl@0
    83
	if (aCapsBuf.MaxLength() < iCapsSize)
sl@0
    84
		{
sl@0
    85
		return KErrArgument;
sl@0
    86
		}
sl@0
    87
sl@0
    88
	TPtrC8 ptr ((TUint8*)iCameraCaps, iCapsSize);
sl@0
    89
	aCapsBuf = ptr;
sl@0
    90
	return KErrNone;
sl@0
    91
	}
sl@0
    92
sl@0
    93
inline TPtrC8 RDevCameraSc::Caps()
sl@0
    94
	{
sl@0
    95
	TPtrC8 ptr((TUint8*)iCameraCaps, iCapsSize);
sl@0
    96
	return ptr;
sl@0
    97
	}
sl@0
    98
sl@0
    99
inline TInt RDevCameraSc::SetBufConfigChunkCreate(TDevCamCaptureMode aCaptureMode, TInt aNumBuffers, RChunk& aChunk)
sl@0
   100
	{return(aChunk.SetReturnedHandle(DoControl(EControlSetBufConfigChunkCreate,(TAny*)aCaptureMode,(TAny*)aNumBuffers)));}
sl@0
   101
sl@0
   102
inline TInt RDevCameraSc::SetBufConfigChunkOpen(TDevCamCaptureMode aCaptureMode, const TDesC8& aBufferConfigBuf, RChunk& aChunk)
sl@0
   103
	{
sl@0
   104
	SSetBufConfigChunkOpenInfo info = {&aBufferConfigBuf, aChunk.Handle()};
sl@0
   105
	return(DoControl(EControlSetBufConfigChunkOpen,(TAny*)aCaptureMode,&info));
sl@0
   106
	}
sl@0
   107
sl@0
   108
inline TInt RDevCameraSc::ChunkClose(TDevCamCaptureMode aCaptureMode)
sl@0
   109
	{return(DoControl(EControlChunkClose,(TAny*)aCaptureMode));}
sl@0
   110
sl@0
   111
inline TInt RDevCameraSc::SetCamConfig(TDevCamCaptureMode aCaptureMode,const TDesC8& aConfigBuf)
sl@0
   112
	{return(DoControl(EControlSetCamConfig,(TAny*)aCaptureMode,(TAny*)&aConfigBuf));}
sl@0
   113
sl@0
   114
inline void RDevCameraSc::GetCamConfig(TDevCamCaptureMode aCaptureMode, TDes8& aConfigBuf)
sl@0
   115
	{DoControl(EControlGetCamConfig,(TAny*)aCaptureMode,(TAny*)&aConfigBuf);}
sl@0
   116
sl@0
   117
inline void RDevCameraSc::GetBufferConfig(TDevCamCaptureMode aCaptureMode, TDes8& aConfigBuf)
sl@0
   118
	{DoControl(EControlGetBufferConfig,(TAny*)aCaptureMode,(TAny*)&aConfigBuf);}
sl@0
   119
sl@0
   120
inline TInt RDevCameraSc::SetCaptureMode(TDevCamCaptureMode aCaptureMode)
sl@0
   121
	{return(DoControl(EControlSetCaptureMode,(TAny*)aCaptureMode));}
sl@0
   122
sl@0
   123
inline TInt RDevCameraSc::Start()
sl@0
   124
	{return(DoControl(EControlStart));}
sl@0
   125
sl@0
   126
inline TInt RDevCameraSc::Stop()
sl@0
   127
	{return(DoControl(EControlStop));}
sl@0
   128
sl@0
   129
inline void RDevCameraSc::NotifyNewImage(TRequestStatus& aStatus)
sl@0
   130
	{DoRequest(ERequestNotifyNewImage,aStatus);}
sl@0
   131
sl@0
   132
inline void RDevCameraSc::NotifyNewImageCancel()
sl@0
   133
	{DoCancel(1<<ERequestNotifyNewImage);}
sl@0
   134
sl@0
   135
inline void RDevCameraSc::NotifyNewImageCancel(const TRequestStatus& aStatus)
sl@0
   136
	{DoControl(EControlNotifyNewImageSpecificCancel,(TAny*)&aStatus);}
sl@0
   137
sl@0
   138
inline TInt RDevCameraSc::ReleaseBuffer(TInt aBufferId)
sl@0
   139
	{return(DoControl(EControlReleaseBuffer,(TAny*)aBufferId));}
sl@0
   140
sl@0
   141
inline TInt RDevCameraSc::BufferIdToOffset(TDevCamCaptureMode aCaptureMode, TInt aId, TInt& aOffset)
sl@0
   142
	{
sl@0
   143
	// search criteria
sl@0
   144
	TDevCamBufferModeAndIdBuf databuf;
sl@0
   145
	TDevCamBufferModeAndId &data = databuf();
sl@0
   146
	data.iCaptureMode = aCaptureMode;
sl@0
   147
	data.iId = aId;
sl@0
   148
sl@0
   149
	return (DoControl(EControlBufferIdToOffset,(TAny*)&databuf,(TAny*)&aOffset));
sl@0
   150
	}
sl@0
   151
sl@0
   152
inline TInt RDevCameraSc::CapsSize()
sl@0
   153
	{return(iCapsSize);}
sl@0
   154
sl@0
   155
inline TInt RDevCameraSc::FrameSizeCaps(TDevCamCaptureMode aCaptureMode, TUidPixelFormat aUidPixelFormat, TDes8& aFrameSizeCapsBuf)
sl@0
   156
	{
sl@0
   157
	SFrameSizeCapsInfo info = {aUidPixelFormat, aCaptureMode};
sl@0
   158
	return(DoControl(EControlFrameSizeCaps, (TAny*)&aFrameSizeCapsBuf, &info));
sl@0
   159
	}
sl@0
   160
sl@0
   161
//
sl@0
   162
//
sl@0
   163
//
sl@0
   164
inline TInt RDevCameraSc::CheckAttributeSupported(TDevCamDynamicAttribute aAttribute)
sl@0
   165
	{
sl@0
   166
	TUint mask = 0;
sl@0
   167
	
sl@0
   168
	switch (aAttribute)
sl@0
   169
		{
sl@0
   170
		case ECamAttributeBrightness:
sl@0
   171
			mask = KCamMiscBrightness;
sl@0
   172
			break;
sl@0
   173
			
sl@0
   174
		case ECamAttributeContrast:
sl@0
   175
			mask = KCamMiscContrast;
sl@0
   176
			break;
sl@0
   177
			
sl@0
   178
		case ECamAttributeColorEffect:
sl@0
   179
			mask = KCamMiscColorEffect;
sl@0
   180
			break;
sl@0
   181
			
sl@0
   182
		default:
sl@0
   183
			return KErrNotSupported;
sl@0
   184
		}
sl@0
   185
	
sl@0
   186
	// Check that the attribute is supported by the hardware.
sl@0
   187
	return (iCameraCaps->iCapsMisc & mask ? KErrNone : KErrNotSupported);
sl@0
   188
	}
sl@0
   189
	
sl@0
   190
//
sl@0
   191
//
sl@0
   192
//
sl@0
   193
inline TInt RDevCameraSc::SetDynamicAttribute(TDevCamDynamicAttribute aAttribute, TUint aValue)
sl@0
   194
	{
sl@0
   195
	TInt err = CheckAttributeSupported(aAttribute);
sl@0
   196
	if (err == KErrNone)
sl@0
   197
		{
sl@0
   198
		err = KErrArgument;
sl@0
   199
		TDynamicRange &range = iCameraCaps->iDynamicRange[aAttribute];
sl@0
   200
		if ((aValue >= range.iMin) && (aValue <= range.iMax))
sl@0
   201
			{
sl@0
   202
			err = DoControl(EControlSetDynamicAttribute, (TAny*)aAttribute, (TAny*)aValue);
sl@0
   203
			}
sl@0
   204
		}
sl@0
   205
sl@0
   206
	return err;
sl@0
   207
	}
sl@0
   208
sl@0
   209
//
sl@0
   210
//
sl@0
   211
//
sl@0
   212
inline TInt RDevCameraSc::GetDynamicAttribute(TDevCamDynamicAttribute aAttribute, TUint& aValue)
sl@0
   213
	{
sl@0
   214
	TInt err = CheckAttributeSupported(aAttribute);
sl@0
   215
	if (err == KErrNone)
sl@0
   216
		{
sl@0
   217
		err = DoControl(EControlGetDynamicAttribute, (TAny*)aAttribute, (TAny*)&aValue);
sl@0
   218
		}
sl@0
   219
		
sl@0
   220
	return err;
sl@0
   221
	}
sl@0
   222
#endif	// __KERNEL_MODE__